© Jeff Friesen 2019
Jeff FriesenJava XML and JSONhttps://doi.org/10.1007/978-1-4842-4330-5_5

5. Selecting Nodes with XPath

Jeff Friesen1 
(1)
Dauphin, MB, Canada
 

Java includes an XPath API for simplifying access to a DOM tree’s nodes. Chapter 5 introduces you to XPath.

What Is XPath?

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 1-1’s third ingredient element and return this element node.

As well as simplifying access to a DOM tree’s nodes, XPath is commonly used in the context of XSLT (discussed in Chapter 6) where it’s typically employed to select (via XPath expressions) those input document elements that are to ...

Get Java XML and JSON: Document Processing for Java SE now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.