0

I have the following XML and would like to get the name and it's value back:

<?xml version="1.0" encoding="UTF-8"?>
<company>
    <name>Company A</name>
    <values>
        <value>20000</value>
    </values>
    <name>Company B</name>
    <values>
        <value>40000</value>
   </values>
</company>

I'm looking for a XPATH that give me something like the following back:

Company A : 20000 Company B : 40000

Any ideas? Is there a function for this?

  • XPath 1.0 or 2.0? I don't think this can be done in a single XPath 1.0 expression so for that we'd need to know what tool/library/programming language you're using - you could use one XPath expression to select each `name` element and then another expression executed for each of these elements in turn to construct the output you want. – Ian Roberts Apr 08 '14 at 17:32
  • You effectively need to select sibling nodes, and then process them. See: http://stackoverflow.com/questions/3139402/how-to-select-following-sibling-xml-tag-using-xpath for more information. – Steve Guidi Apr 08 '14 at 19:02

0 Answers0