什么是比较平等的XML文件的最好方法是什么? [英] What is the best way to compare XML files for equality?

查看:166
本文介绍了什么是比较平等的XML文件的最好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是.NET 2.0,而最近code修改已经失效我的previous Assert.AreEqual调用(这比XML​​的两个字符串)。只有一个元素的XML是在新的codeBase的实际上是不同的,所以我希望的是所有其他元素的比较,给我我想要的结果。比较需要通过编程完成,因为它是一个单元测试的一部分。

I'm using .NET 2.0, and a recent code change has invalidated my previous Assert.AreEqual call (which compared two strings of XML). Only one element of the XML is actually different in the new codebase, so my hope is that a comparison of all the other elements will give me the result I want. The comparison needs to be done programmatically, since it's part of a unit test.

起初,我正在考虑使用XmlDocument的一对夫妇的实例。但后来我发现这一点: <一href="http://drowningintechnicaldebt.com/blogs/scottroycraft/archive/2007/05/06/comparing-xml-files.aspx" rel="nofollow">http://drowningintechnicaldebt.com/blogs/scottroycraft/archive/2007/05/06/comparing-xml-files.aspx

At first, I was considering using a couple instances of XmlDocument. But then I found this: http://drowningintechnicaldebt.com/blogs/scottroycraft/archive/2007/05/06/comparing-xml-files.aspx

它看起来像它可能工作,但我的情况下感兴趣的堆栈溢出的反馈有一个更好的办法。

It looks like it might work, but I was interested in Stack Overflow feedback in case there's a better way.

我想避免添加其他依赖此,如果在所有可能的。

I'd like to avoid adding another dependency for this if at all possible.

  • Is there an XML asserts for NUnit?
  • How would you compare two XML Documents?

推荐答案

这真的取决于你要检查的差异是什么。

It really depends on what you want to check as "differences".

目前,我们正在使用微软的xmldiff:<一href="http://msdn.microsoft.com/en-us/library/aa302294.aspx">http://msdn.microsoft.com/en-us/library/aa302294.aspx

Right now, we're using Microsoft XmlDiff: http://msdn.microsoft.com/en-us/library/aa302294.aspx

这篇关于什么是比较平等的XML文件的最好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆