2

我正在寻找一个 XPath 表达式,它选择him具有子、kid's 和父级的 s,gramps's 和first's 都是相同的。在下面的示例中,这将只是Bill.

<root>

<gramps first="Bill">
   <him first="Bill">
      <kid first="Bill"></kid>
   </him>
</gramps>
<gramps first="Tom">
   <him first="Al">
      <kid first="Al"></kid>
   </him>
</gramps>
<gramps first="Bob">
   <him first="Bob">
      <kid first="Sam"></kid>
   </him>
</gramps>

</root>
4

1 回答 1

2
//gramps/him[@first=kid/@first and @first=../@first]

演示在这里 - http://www.xpathtester.com/obj/6f8c493b-368c-47bb-a1f9-45191375f177

于 2013-09-03T04:00:14.233 回答