简体   繁体   English

XML/XPath:通过兄弟姐妹区分相等的节点

[英]XML/XPath: Distinguish equal nodes via siblings

I have an XML of the following form:我有以下形式的 XML:

<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?有没有办法只找到没有前兄弟的元素C 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?我正在研究XPathXPathAxes ,但没有想出一个解决方案......有谁知道是否有办法使用 Xpath-syntax 来实现这一点?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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