XPath 节点

n XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes.
在XPath里,有7种不同的节点:元素、属性、文本、命名空间、处理指令、注释、文档(根目录)节点。


XPath Terminology
XPath 术语

Nodes
节点

In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes. XML documents are treated as trees of nodes. The root of the tree is called the document node (or root node).
在XPath里,有7种不同的节点:元素、属性、文本、命名空间、处理指令、注释、文档(根目录)节点。XML文档将被处理成节点树状结构。树状结构的“根部” 称为文档节点(或根节点)。

Look at the following XML document:
看看下面这份XML文档:

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
<title lang="en">Harry Potter</title>

<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>

Example of nodes in the XML document above:
下面列举的是上述XML文档中的节点实例:

<bookstore>  (document node)
<author>J K. Rowling</author>  (element node)
lang="en"  (attribute node)

Atomic values
原子值(Atomic values)

Atomic values are nodes with no children or parent.
“原子值”就是不包含子节点和父节点的节点。

Example of atomic values:
“原子值”案例:

J K. Rowling
"en"

Items

Items are atomic values or nodes.
“项”就是原子值或节点。


Relationship of Nodes
节点间的关系

Parent
父类元素

Each element and attribute has one parent.
每个元素和属性都包含一个“父类元素”。

In the following example; the book element is the parent of the title, author, year, and price:
在下述案例中,book 元素是 title、author、year 和 price 元素的父元素:

<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>

<year>2005</year>
<price>29.99</price>
</book>

Children
子类元素

Element nodes may have zero, one or more children.
元素 节点可以包含任意数量的子类元素,也可以不包含任何子类元素。

In the following example; the title, author, year, and price elements are all children of the book element:
在下述案例中,title、author、year 和 price 元素都是book 元素的子类元素:

<book>
<title>Harry Potter</title>

<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>

Siblings
同类元素

Nodes that have the same parent.
拥有相同父类元素的节点称为同类元素。

In the following example; the title, author, year, and price elements are all siblings:
在下述案例中,title、author、year 和 price 元素都是“同类元素”:

<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>

<price>29.99</price>
</book>

Ancestors
祖类元素

A node's parent, parent's parent, etc.
一个节点的父类元素、父类元素的父类元素,以此类推,统称为该节点的祖类元素。

In the following example; the ancestors of the title element are the book element and the bookstore element:
在下述案例中,title元素的祖类元素是 book 元素和 bookstore 元素:

<bookstore>
<book>
<title>Harry Potter</title>

<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>

Descendants
孙类元素

A node's children, children's children, etc.
一个节点的子类元素,子类元素的子类元素,以此类推,统称为该元素的孙类元素。

In the following example; descendants of the bookstore element are the book, title, author, year, and price elements:
在下述案例中,bookstore 元素的孙类元素是book、title、author、year 和 price 元素:

<bookstore>
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>

<price>29.99</price>
</book>
</bookstore>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值