© Jeff Friesen 2016

JEFF FRIESEN, Java XML and JSON, 10.1007/978-1-4842-1916-4_5

5. Selecting Nodes with XPath

Jeff Friesen

(1)Dauphin, Manitoba, Canada

Java includes an XPath API for simplifying access to a DOM tree’s nodes. This chapter 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 be ...

Get Java XML and JSON now with the O’Reilly learning platform.

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