2

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>
  • 1
    Hi, welcome to StackOverflow! This looks like a good question, but your last sentence is basically equivalent to "my XPathSelect code doesn't work." That's not very helpful. Can you please post your XPathSelect code that isn't working and explain what it's doing that's wrong? That will make it much easier to help you find a way to fix it. Thanks. – Mason Wheeler Dec 28 '11 at 17:51

1 Answers1

2

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.

Ken White
  • 123,280
  • 14
  • 225
  • 444