开发者

XPath selecting a node with some attribute value equals to some other node's attribute value [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audi开发者_JAVA技巧ence of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.
<grand id="grand">
  <parent>
    <child age="18" id="#not-grand"/>
    <child age="20" id="#grand"/> <!-- This is what I want to locate -->
  </parent>
</grand>

Can anybody tell me how to express for locating the second child?

This doesn't work...

"/grand/parent/child[@id=concat('#',/grand/@id)]/@age"

Thank you.


I'm sorry. The expression is OK. I found I got some problems in other area not the expression itself.


This XPath is specific to the code snippet you've provided. To select <child> with id as #grand you can write //child[@id='#grand'].

To get age //child[@id='#grand']/@age.


I think this is what you want:

/grand/parent/child[@id="#grand"]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜