Reputation: 35
Using OmniXML and Delphi, I would like to locate an element and change another element in the node. For example, in the xml listing below, I would like to locate /first-name = 'Joe1' and then locate and change the /price from 1200 to 10. I've tried using XPathSelect but I can not seem to specify the /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>
Upvotes: 2
Views: 649
Reputation: 125748
Use //book[author/first-name = "Joe1" ]
as your XPathSelect
query to get the node, and then access the subnode Price
from that node to change it.
Upvotes: 2