這是我的xml:如何在循環期間更新或追加XML節點?
<rootNode>
<sample>
<DO type="TD" name="ABC" ref="1">
<text>text</text>
</DO>
<DO type="CI" name="DEF" ref="2">
<text></text>
</DO>
<DO type="PL" name="GHI" ref="3">
<text>text</text>
</DO>
<DO type="AB" name="JKL" ref="4">
<text>text</text>
</DO>
</sample>
<Docs>
<Document>
<type>TD</type>
<name>ABC</name>
<ref>1</ref>
<text>sample text</text>
</Document>
<Document>
<type>CI</type>
<name>DEF</name>
<ref>2</ref>
<text>sample text</text>
</Document>
<Document>
<type>PL</type>
<name>GHI</name>
<ref>3</ref>
<text>sample text</text>
</Document>
<Document>
<type>AB</type>
<name>JKL</name>
<ref>4</ref>
<text>sample text</text>
</Document>
<Document>
<type>CD</type>
<name>JKL</name>
<ref>5</ref>
<text>sample text</text>
</Document>
</Docs>
</rootNode>
如果任何樣品/ DO的類型,名稱和參考文獻與任何文檔/文件類型,名稱和ref的匹配。使用文檔/文本更新樣本/ DO /文本。否則(如果任何樣品/類型,名稱,參考文獻與文檔/文檔類型,名稱,參考文獻不匹配),則應附加整個文檔/文檔。
注意:樣品/ DO的順序不應改變。我的意思是如果任何文件有任何匹配相同應更新。否則應該追加新的。
你使用純xpath還是其他語言 – 2012-04-21 05:58:49
需要使用xpath(1.0或2.0)實現它 – cbx 2012-04-21 06:11:04
@bose:這是什麼意思:「否則(如果任何樣本/ Do的類型,name,ref與Docs/Document類型,name,ref不匹配),那麼應附加從Docs/Document開始的整個Document。「 *應該附加哪個*文檔/文檔?請解釋。 – 2012-04-21 16:33:53