XQuery Terminology
In XQuery, there are seven types of nodes: elements, attributes, text, namespaces, processing instructions, comments, and document nodes (also known as root nodes). XML documents are treated as trees of nodes. The root of the tree is called the document node or root node.
Consider the following XML document:
Examples of nodes in the above XML document:
#
Atomic values are nodes with no parent or children.
Examples of atomic values:
Item
An item is either an atomic value or a node.
Node Relationships
Parent
Each element and attribute has a parent.
In the following example, the book element is the parent of the title, author, year, and price elements:
Children
A node element can have zero, one, or more children.
In the following example, the title, author, year, and price elements are children of the book element:
Sibling
Nodes that have the same parent.
In the following example, the title, author, year, and price elements are siblings:
Ancestor
The parent of a node, 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:
Descendant
The children of a node, the children's children, and so on.
In the following example, the descendants of the bookstore element are the book, title, author, year, and price elements: