Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
XPath is a nonXML declarative query language (defined by the W3C) for selecting an XML document’s infoset items as one or more nodes. For example, you can use XPath to locate Listing 10-1’s third ingredient element and return this element node.
XPath is often used to simplify access to a DOM tree’s nodes, and is also used in the context of XSLT (discussed in the next section), typically to select those input document elements (via XPath expressions) that are to be copied to an output document. Java 7 supports XPath 1.0 via JAXP’s XPath API, which is assigned package javax.xml.xpath.
This section first acquaints you with the XPath 1.0 language. It then demonstrates how XPath simplifies the selection of a DOM tree’s nodes. Lastly, the section introduces you to three advanced XPath topics.