In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document nodes.
XML documents are treated as trees of nodes. The topmost element of the tree is called the root element.
Look at the following XML document:
Example of nodes in the XML document above:
Atomic values are nodes with no children or parent.
Example of atomic values:
Items are atomic values or nodes.
Each element and attribute has one parent.
In the following example; the book element is the parent of the title, author, year, and price:
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:
Nodes that have the same parent.
In the following example; the title, author, year, and price elements are all siblings:
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:
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: