简体   繁体   中英

XML/XPath: Distinguish equal nodes via siblings

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?

基本上就是你所说的: //C[not(preceding-sibling::*)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM