使用OmniXML和Delphi,我想定位一个元素并更改节点中的另一个元素。例如,在下面的xml清单中,我希望找到/first-name = 'Joe1‘,然后找到/price并将其从1200改为10。我尝试使用XPathSelect,但似乎无法指定/first-name。
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myfile.xsl" ?>
<bookstore specialty="novel">
<book style="autobiography">
<author>
<first-name>Joe1</first-name>
<last-name>Bob</last-name>
<award>Trenton Literary Review Honorable Mention</award>
</author>
<price>1200</price>
</book>
<book style="textbook">
<author>
<first-name>Mary</first-name>
<last-name>Bob</last-name>
<publication>Selected Short Stories of
<first-name>Mary</first-name>
<last-name>Bob</last-name>
</publication>
</author>
<editor>
<first-name>Britney</first-name>
<last-name>Bob</last-name>
</editor>
<price>55</price>
</book>
</bookstore>发布于 2011-12-29 01:52:24
使用//book[author/first-name = "Joe1" ]作为XPathSelect查询来获取节点,然后从该节点访问子节点Price以更改它。
https://stackoverflow.com/questions/8658411
复制相似问题