XQuery term
In XQuery, there are seven kinds of nodes: element, attribute, text, namespace, processing instructions, comments, and document node (or root node).
XQuery term
node
In XQuery, there are seven kinds of nodes: element, attribute, text, namespace, processing instruction, comment, and document (root) nodes. XML document is treated as a node tree. Root of the tree is called the document node or root node.
Consider the following XML document:
<bookstore>
<book>
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
The above XML document node examples:
<author>J K. Rowling</author> (元素节点)
lang="en" (属性节点)
The basic value is no father or no child nodes.
Examples of basic values:
"en"
project
Project is the basic values or nodes.
Node Relationship
Parent (Parent)
Each element and attribute has one parent.
In the following example, book element is the parent title, author, year, and price elements:
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
Child (Children)
Node element can have zero, one or more children.
In the following example, title, author, year, and price elements are all children of the book element:
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
Compatriots (Sibling)
It has the same parent node.
In the following example, title, author, year, and price elements are brothers:
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
Ancestor (Ancestor)
The parent of a node, and the parent's parent, and so on.
In the following example, the ancestors of the title element are the book element and the bookstore element:
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
Offspring (Descendant)
Child of a node, sub-sub, and so on.
In the following example, bookstore offspring is book, title, author, year, and price elements:
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>