XPath Node
XPath Terminology
Node
In XPath, there are seven types 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.
Consider the following XML document:
Example nodes in the above XML document:
Atomic Value
An atomic value is a node with no parent or child.
Examples of atomic values:
Item
An item is either an atomic value or a node.
Node Relationships
Parent
Every 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
Element nodes 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 of the parent, etc.
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 of the children, etc.
In the following example, the descendants of the bookstore element are the book, title, author, year, and price elements: