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

我有这个:
<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)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念
xml文件介绍及使用
xml编程(一)-xml语法
XML文件结构和基本语法
第2章 包装类
XML入门的常见问题(二)
Java对象的强、软、弱和虚引用
JS解析XML文件和XML字符串详解
java中枚举的详细使用介绍
了解Xml格式
XML入门的常见问题(四)
深入SQLite多线程的使用总结详解
PlayFramework完整实现一个APP(一)
XML和YAML的使用方法
XML轻松学习总节篇