XPath's primary purpose is to address parts of an XML document. To do that, XPath uses its own, non-XML, syntax. XPath operates on the abstract, logical structure of an XML document, and this logical structure is known as the data model , as we'll see in the next chapter. XPath reduces an XML document to a tree of XML nodes , as we're going to see in detail in Chapter 2, and that's what it actually works with. A node is an individual data item in an XML documentelements can be nodes, XML processing instructions can be nodes, element attributes can be nodes, the text in an element is a text node, XML comments are comment nodes, and so on. The root node is the very beginning of the document, before anything else (before any XML elements, processing instructions, or anything else).
To work with the nodes in an XML document, you use XPath expressions , which are the primary construct in XPath. An XPath expression is a term or group of terms that XPath can evaluate to produce a result.
Probably the most important type of XPath expression is the location path , and for many people, this is what XPath is all about, because you use a location path to select a set of nodes (which may contain just a single node). Using a location path, you can tell XPath exactly what data you want to extract from an XML document.