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