在C#中的XML的比较 [英] Xml Comparison in C#
问题描述
我试图比较使用C#code两个XML文件。
我想忽略XML语法的差异(即preFIX名称)。
对于我使用微软的<一个href=\"http://www.microsoft.com/downloads/details.aspx?FamilyID=3471df57-0c08-46b4-894d-f569aa7f7892&DisplayLang=en\">XML diff和patch C#API。
它适用于某些XML的,但我无法找到一个方法来配置它一起工作了以下两个XML的:
XML答:
&LT;根系的xmlns:NS =HTTP:// myns名字&GT;
&LT; NS:孩子&GT; 1 LT; / NS:孩子&GT;
&LT; /根&GT;
XML乙:
&LT;根和GT;
&LT;儿童的xmlns =HTTP:// myns名字&GT; 1 LT; /儿童&GT;
&LT; /根&GT;
我的问题是:
- 我说得对,这两个XML的在语义上是相等的(或同构)?
- 能否微软的XML diff和patch API进行配置,以支持它?
- 是否有任何其他C#工具来这样做呢?
我有<一个href=\"http://social.msdn.microsoft.com/Forums/en-US/xmlandnetfx/thread/3f2bb47f-356d-48f3-866c-b2533e5731f8/\"相对=nofollow>马丁Honnen 在XML和.NET Framework MSDN论坛答案。
总之,他建议使用XQuery 1.0的深相等功能,并提供了一些C#实现。似乎工作。
I'm trying to compare two Xml files using C# code. I want to ignore Xml syntax differences (i.e. prefix names). For that I am using Microsoft's XML Diff and Patch C# API. It works for some Xml's but I couldn't find a way to configure it to work with the following two Xml's:
XML A:
<root xmlns:ns="http://myNs">
<ns:child>1</ns:child>
</root>
XML B:
<root>
<child xmlns="http://myNs">1</child>
</root>
My questions are:
- Am I right that these two xml's are semantically equal (or isomorphic)?
- Can Microsoft's XML Diff and Patch API be configured to support it?
- Are there any other C# utilities to to this?
I've got an answer by Martin Honnen in XML and the .NET Framework MSDN Forum. In short he suggests to use XQuery 1.0's deep-equal function and supplies some C# implementations. Seems to work.
这篇关于在C#中的XML的比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!