.NET 中两个 XML 文件逐节点比较
我想逐个节点比较两个 xml 文件(以检查两个文件是否包含具有相同属性的相同节点等),并突出显示两个 xml 文件中的差异,并使用 . NET
另外我想知道除了使用 .NET 之外还有哪些比较 xml 文件的方法
有人可以让我深入了解一下吗?
I want to compare two xml files node by node(to check if both contain the same nodes with the same attributes,etc) and highlight the differences in the two xml files and print the nodes which are missing in either of the xml files using .NET
Also I would like to know what are all the methods of comparing xml files other than using .NET
Could someone give me an insight into this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,您可以使用像这样的开源库,而不是手动编写算法:http://diffplex.codeplex。 com/ 它进行逐行比较,而不是逐节点比较,但它会为您省去手动实现所有突出显示和视觉效果的麻烦。
Well rather than writing an algorithm manually, you can use an open-source library like this one: http://diffplex.codeplex.com/ It does a line by line comparison rather than node-by-node comparison but it will save you the hassle of implementing all the highlighting and visuals by hand.
如果你知道 xml 的结构,你可以将其反序列化为对象并以这种方式进行比较,这将处理乱序的事情和看起来像的节点>与 。
<代码>
否则,就更困难了。查看此链接:XmlDiff
if you know the structure of your xml, you can deserialize it into objects and compare that way, this will take care of things being out of order and nodes looking like
<foo /> vs <foo></foo>
.otherwise, it's more difficult. check out this link: XmlDiff