XPath is a language for finding information in XML documents.

XPath node syntax

In XPath, there are seven types of nodes: element, attribute, text, namespace, processing directive, comment, and document (root) node. XML documents are treated as nodes trees. The root of the tree is called the document node or root node.

XPath node example

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>

Example of nodes in the above XML document:

<bookstore> (document node)
<author>J K. Rowling</author> (element node)
lang="en" (attribute node)