这是我的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