加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

选择一个XML元素,与XPATH无关

发布时间:2020-12-16 07:41:44 所属栏目:百科 来源:网络整理
导读:我有这个: a b ttext/t /b/aa ttext/t/a 所以我想选择文本,不管它在哪里. (注意,它可以在任何地方不只是1/2级别,它可以没有父母) 这可能吗? 您正在寻找 the descendant axis: the descendant axis contains the descendants of the context node; a desce
我有这个:
<a>
  <b>
    <t>text</t>
  </b>
</a>
<a>
  <t>text</t>
</a>

所以我想选择文本,不管它在哪里.
(注意,它可以在任何地方不只是1/2级别,它可以没有父母)

这可能吗?

您正在寻找 the descendant axis:

the descendant axis contains the descendants of the context node; a
descendant is a child or a child of a
child and so on; thus the descendant
axis never contains attribute or
namespace nodes

在你的情况下:/后代:t

当然,正如其他人回答的那样,there is an abbreviated syntax for this:

// is short for /descendant-or-self::node()/. For
example,//para is short for
/descendant-or-self::node()/child::para
and so will select any para element
in the document (even a para element
that is a document element will be
selected by //para since the document element node is a child of the root node)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读