Selecting Values in XPath depending on values at same level



I've got this partial XML



<Events>
<Properties>
<Property Descriptor="1">VALUE1</Property>
<Property Descriptor="2">FOO</Property>
<Property Descriptor="3">BAR</Property>
</Properties>
<Properties>
<Property Descriptor="1">VALUE2</Property>
<Property Descriptor="2">NO</Property>
<Property Descriptor="3">NOTHINGHERE</Property>
</Properties>
</Events>


Hi can I query the first occurrence of Property Descriptor="3" when Property Descriptor="2" = "FOO"? Result here should be BAR


I tried //Properties/Property[@Descriptor="3"][..//Property[@Descriptor="2"] = "FOO"] but it's now working.


No comments:

Post a Comment