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

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

问题描述

我使用的是.NET 2.0,最近的代码更改使我以前的Assert.AreEqual调用(比较了两个XML字符串)失效。只有XML的一个元素实际上在新的代码库不同,所以我的希望是所有其他元素的比较将给我我想要的结果。比较需要以编程方式完成,因为它是单元测试的一部分。



首先,我考虑使用几个XmlDocument实例。但是后来我发现这个:
http://drowningintechnicaldebt.com/blogs/scottroycraft/archive/2007/05/06/comparing-xml-files.aspx



看起来像可能工作,但我有兴趣的Stack Overflow反馈,如果有一个更好的方法。



我想避免添加另一个依赖关系,如果可能的话。 / p>

类似问题




解决方案

这取决于你想要检查为差异。



右现在,我们正在使用Microsoft XmlDiff: http://msdn.microsoft.com /en-us/library/aa302294.aspx


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.

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.

Similar questions

解决方案

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

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

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

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