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.
<?xml version="1.0" encoding="UTF-8"?> <bookstore> <book> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>
In the above XML document.
<bookstore> (root element node) <author>J K. Rowling</author> (element node) lang="en" (attribute node) J K. Rowling (these atomic values have no parent or child) "en" (these atomic values have no parent or child)
The book element is the parent of the title, author, year, and price. Element nodes may have zero, one or more children. In the example; the title, author, year, and price elements are all children of the book element. Siblings are nodes that have the same parent. Title, author, year, and price elements are all siblings. The ancestors of the title element are the book element and the bookstore element. Descendants of the bookstore element are the book, title, author, year, and price elements. Items are atomic values or nodes.