Home > Mobile >  XML/XPath: Distinguish equal nodes via siblings
XML/XPath: Distinguish equal nodes via siblings

Time:06-25

I have an XML of the following form:

<A>
  <B>
    <C/> <!-- Want to find ONLY this C -->
  </B>
  <B>
    <D/>
    <C/>
  </B>
</A>

Is there a way of only finding the element C which has no preceding-sibling? I was looking into XPath and XPathAxes, but did not come up with a solution... Does anyone know if there is a way with Xpath-syntax to achieve this?

CodePudding user response:

It is basically what you say: //C[not(preceding-sibling::*)].

  • Related