概述
(转自:http://www.w3schools.com/xpath/xpath_nodes.asp)
XPath Nodes
In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes.
XPath Terminology
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).
Look at the following XML document:
|
Example of nodes in the XML document above:
|
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>
xml 代码
</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:
<book>
xml 代码
<author></author><price> </book> |
Siblings
Nodes that have the same parent.
In the following example; the title, author, year, and price elements are all siblings:
<book>
xml 代码
</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:
<bookstore></bookstore> <book><author></author><year></year><price></price>
xml 代码
xml 代码
</book> |
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></bookstore>
<book>
<price>
- <bookstore>
- <book>
- <title>Harry Potter</title>
- <author>J K. Rowling</author>
- <year>2005</year>
- <price>29.99</price>
- </book>
- </bookstore>
</book>
最后
以上就是拉长抽屉为你收集整理的xpath 语法(节点)XPath Nodes的全部内容,希望文章能够帮你解决xpath 语法(节点)XPath Nodes所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复