当前位置: 首页 > 网络学院 > XML相关教程 > XPath > XPath 节点

XPath
XPath 介绍
XPath 节点
XPath 语法
XPath 坐标轴
XPath 操作符
XPath 实例
XPath 摘要
XPath 函数

XPath 节点


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 684 ::
收藏到网摘: n/a

In 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) All

登陆 | 还没注册?