Navigating an XML Document with XPath

The XPath standard defines how you refer to an element in an XML document. XPath is basically a query mechanism that lets you identify nodes based on a certain pattern. The pattern can be the node's value, its children, its attributes, and even its relationship to other nodes. For example, you've already seen XSL template rules that use / to match the root element and . to match the current element. These are both XPath expressions.

For example, if you want to refer to the firstName element that is a child of the person element, you can use the XPath expression person/firstName. In some ways, it is similar to the convention you use for naming files. XPath is more than just a naming standard, however; it is ...

Get Special Edition Using Java™ 2 Enterprise Edition 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.