I have this structure:
<root>
<properties>
<property name="test">
<value>X</value>
</property>
</properties>
<things>
<thing>
<properties>
<property name="test">
<value>Y</value>
</property>
</properties>
</thing>
</things>
</root>
Is there an XPath expression which will select only the test property with value X if run with <root> as root, and only the one with value Y if run with thing as root?
I thought that /properties/property[@name='test'] would require it to be a direct child, but that seems to return nothing. If I remove the slash, I get both property elements (I’m using C#, with XElement root = ...; root.XPathSelectElements(xpathexpression);).
I think you mean
Propertyand notProperties. Try./properties/property[@name='test']