© 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 
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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.