NET 4.0中的XML比较

编程入门 行业动态 更新时间:2024-10-26 10:29:52
本文介绍了NET 4.0中的XML比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在执行当前任务时,在比较2个xml文件时遇到问题. 也许有人知道我可以以哪种方式在NET 4.0中尽可能快地比较那些文件. 比较的主要思想是断言那些文件是相同的: -没有添加节点 -没有删除任何节点 -不会更改任何值. 所有答案都将被视为可接受=) 乍一看,我希望通过比较文档文本来考虑它们的相等性,但是现在,我的方式是sucks =))

Working on my current task I''m encountered with problem in comparison of 2 xml files. Maybe anybody knows in which way i could compare those files as fast as it possible in NET 4.0. The main idea of comparison is to assert, that those documents are identical: - no nodes are added - no nodes are removed - no values are changed. All answers will consider as acceptable =) At first mind , i look forward to consider their equality by comparing text of documents, but i now, that way is sucks =))

推荐答案

看看这个Microsoft关于XML差异的文章: MSDN:在应用程序中使用XML差异和补丁工具 [ ^ ] 另一种方式:使用LINQ在XML文件中进行差异 [ ^ ] 一个有趣的开源项目: DiffPlex-.NET Diff生成器 [ ^ ] Have a look at this Microsoft article on XML Difference: MSDN: Using the XML Diff and Patch Tool in Your Applications[^] Another way: Diff in XML files with LINQ[^] An interesting open source project: DiffPlex - a .NET Diff Generator[^]

最简单的方法是读取字符串对象中的两个文件,然后检查两个字符串是否相等(使用区分大小写的字符串比较).唯一要考虑的是几个节点之间的额外空间. The easiest way is read both the files in string object and check if both the strings are equal (use string comparision with case sensitive). The only thing to consider on top of this is additional spaces between few nodes.

更多推荐

NET 4.0中的XML比较

本文发布于:2023-11-09 05:22:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571494.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!