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

前端之家收集整理的这篇文章主要介绍了选择一个XML元素,与XPATH无关前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个:
<a>
  <b>
    <t>text</t>
  </b>
</a>
<a>
  <t>text</t>
</a>

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

这可能吗?

您正在寻找 the descendant axis

the @H_404_14@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

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

猜你在找的XML相关文章