XPath选择具有某些属性值的节点等于某些其他节点的属性值 [英] XPath selecting a node with some attribute value equals to some other node's attribute value

查看:48
本文介绍了XPath选择具有某些属性值的节点等于某些其他节点的属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<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?

这不起作用...

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

谢谢.

对不起.表情没问题.我发现我在其他方面遇到了一些问题,而不是表达本身.

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

推荐答案

此 XPath 特定于您提供的代码片段.要选择 ,id 为 #grand,您可以编写 //child[@id='#grand'].

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

获取年龄//child[@id='#grand']/@age

希望能帮到你

这篇关于XPath选择具有某些属性值的节点等于某些其他节点的属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆