I’m having trouble figuring out how to select data using a compound XPath query so that I can essentially find the 5th column of row in my data. Here is my example XML:
<sample>
<OBX>
<field position="1">1</field>
<field position="2">My Value</field>
</OBX>
<OBX>
<field position="1">2</field>
<field position="2">My other (and more important) value</field>
</OBX>
</sample>
Basically all I need to do is find the value of [field @position=’2′] when [field @position=’1′] is equal to 2. I am trying:
OBX[./field[@position='1']='2']/field[@position='2']
but this doesn’t come up with any value. What would be the proper way to get this accomplished?
Thanks,
Mike
I have verified that this XPath expression:
when evaluated against the provided XML document:
does select the required node
Here is a demonstration, using XSLT as the XPath hosting language:
when this transformation is applied against the provided XML document, the correct result is produced: