3
我使用XMLdiffpatch
工具来检测两个XML文件之间变化的节点名称,该工具的输出XML文件看起来像这样:获取在输出中的DiffGram,而不是他们的索引
<?xml version="1.0" encoding="utf-16"?>
<xd:xmldiff version="1.0" srcDocHash="5708212576896487287" options="None" fragments="no" xmlns:xd="http://www.microsoft.com/xmldiff">
<xd:node match="2">
<xd:node match="3"/>
<xd:add>
<e>Some text 4</e>
<f>Some text 5</f>
</xd:add>
<xd:node match="4">
<xd:change match="1">Changed text</xd:change>
<xd:remove match="2"/>
</xd:node>
<xd:node match="5">
<xd:remove match="@secondAttr"/>
<xd:add type="2" name="newAttr">new value</xd:add>
<xd:change match="@firstAttr">changed attribute value</xd:change>
</xd:node>
<xd:remove match="6" opid="1"/>
<xd:add type="1" name="p">
<xd:add type="1" name="q">
<xd:add match="/2/6" opid="1"/>
</xd:add>
</xd:add>
</xd:node>
<xd:descriptor opid="1" type="move"/>
</xd:xmldiff>
第一个文件:
<?xml version="1.0"?>
<b>
<a>Some text 1</a>
<b>Some text 2</b>
<c>Some text 3</c>
<d>
Another text
<foo/>
</d>
<x firstAttr="value1" secondAttr="value2"/>
<y>
<!--Any comments?-->
<z id="10">Just another text</z>
</y>
</b>
第二个文件:
<?xml version="1.0"?>
<b>
<a>Some text 1</a>
<b>Some text 2</b>
<c>Some text 3</c>
<e>Some text 4</e>
<f>Some text 5</f>
<d>Changed text</d>
<x firstAttr="changed attribute value" newAttr="new value"/>
<p>
<q>
<y>
<!--Any comments?-->
<z id="10">Just another text</z>
</y>
</q>
</p>
</b>
如你所见,在xml显示检测到的节点改变其索引对应于其父节点。 我现在面临的问题是如何解析这些索引,以便将它们替换为原始xml文件中的实际节点名称。
是的,一个c#控制台应用程序 – 2013-04-10 08:29:37
您需要发布两个XML文件,其中输入到XMLDiffPatch作为数据没有意义,否则。 – TheKingDave 2013-04-10 08:35:37
非常抱歉没有这样做,从第一次!我上传他们,编辑我的原始帖子 – 2013-04-10 09:11:42