比较在.NET 2 XML文档的最佳方式 [英] Best way to compare 2 XML documents in .NET

查看:89
本文介绍了比较在.NET 2 XML文档的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有需要检查XML输出​​单元测试堆。

我已经开始了比较字符串但这不会扩展格式化和表面差异的方式获得。

什么是.NET中最简单的方法来评估生成的XML是否是语义上的相同的测试期望是什么?

  

关闭作为你会如何比较两个XML文档?

解决方案

微软提供的XML比较工具/班的这里。我没有亲自使用过它,但它听起来像它会帮助您入门:

  

使用中的xmldiff班,   程序员能够确定是否   两个文件其实都是基于不同   上是重要的条件   他们的应用程序

这似乎应付不同的顺序,间隔,空间prefixes等。

I have a heap of unit tests that need to check XML outputs.

I have started out comparing strings but this isn't going to scale as formatting and superficial differences get in the way.

What is the easiest way in .NET to evaluate whether the generated XML is semantically the same as what the test expects?

Closed as duplicate of How would you compare two XML Documents?

解决方案

Microsoft offers its XML Diff tools/classes here. I haven't personally used it, but it sounds like it'll get you started:

"By using the XMLDiff class, the programmer is able to determine if the two files are in fact different based on the conditions that are important to their application"

It seems to cope with different ordering, spacing, namespace prefixes etc.

这篇关于比较在.NET 2 XML文档的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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