- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
XPath 节点
XPath 术语
节点(Node)
在 XPath 中,有七种类型的节点:元素、属性、文本、命名空间、处理指令、注释以及文档(根)节点。
XML 文档是被作为节点树来对待的。树的根被称为文档节点或者根节点。请看下面这个 XML 文档:
?xml version=1.0 encoding=ISO-8859-1?
bookstore
book
title lang=enHarry Potter/title
authorJ K. Rowling/author
year2005/year
price29.99/price
/book
/bookstore
上面的 XML 文档中的节点例子:
bookstore (文档节点)
authorJ K. Rowling/author (元素节点)
lang=en (属性节点)
基本值(或称原子值,Atomic value) 基本值是无父或无子的节点。
基本值的例子:
J K. Rowling en项目(Item)
J K. Rowling en
项目是基本值或者节点。
节点关系
父(Parent)
每个元素以及属性都有一个父。
booktitleHarry Potter/titleauthorJ K. Rowling/authoryear2005/yearprice29.99/price/book在下面的例子中,book 元素是 title、author
book
titleHarry Potter/title
authorJ K. Rowling/author
year2005/year
price29.99/price
/book
子(Children)
元素节点可有零个、一个或多个子。
booktitleHarry Potter/titleauthorJ K. Rowling/authoryear2005/yearprice29.99/price/book同胞(Sibling)拥有相同的父的节点在下面的例子中,title
book
titleHarry Potter/title
authorJ K. Rowling/author
year2005/year
price29.99/price
/book
同胞(Sibling)
拥有相同的父的节点
booktitleHarry Potter/titleauthorJ K. Rowling/authoryear2005/yearprice29.99/price/book在下面的例子中,title、author
book
titleHarry Potter/title
authorJ K. Rowling/author
year2005/year
price29.99/price
/book
先辈(Ancestor)
某节点的父、父的父,等等。
bookstorebooktitleHarry Potter/titleauthorJ K. Rowling/authoryear2005/yearprice29.99/price/book/bookstore
bookstore
book
titleHarry Potter/title
authorJ K. Rowling/author
year2005/year
price29.99/price
/book
/bookstore
后代(Descendant)
某个节点的子,子的子,等等。
bookstorebook在下面的例子中,bookstore 的后代是 book、title、author、year 以及 price
bookstore
book
titleHarry Potter/titleauthorJ K. Rowling/authoryear2005/year
titleHarry Potter/title
authorJ K. Rowling/author
year2005/year
price29.99/price
/book
/bookstore
XPath 使用路径表达式来选取 XML 文档中的节点或节点集。节点是通过沿着路径 (path) 或者步
(steps) 来选取的。
XML 实例文档
我们将在下面的例子中使用这个 XML 文档。
?xml version=1.0 encoding=ISO-8859-1?
bookstore
book
title lang=engHarry Potter/title
price29.99/price
/book
book
title lang=engLearning XML/title
price39.95/price
/book
/bookstore
选取节点
XPath 使用路径表达式在 XML 文档中选取节点。节
文档评论(0)