Chapter 16. XPath

Much of the code in this book has involved navigating the tree structure of an XML document to find particular nodes. For example, the XML-RPC servlet in Example 10.13 read a client request looking for int elements. Such code can become quite involved and fragile if you aren't very careful. As the code walks down the tree hierarchy, loading one child after the other, a single misplaced or misnamed element may cause the program to fail. If an element isn't where it's expected to be, then the chain of method calls that gives directions to the desired elements will be broken. What's needed is a way to specify which nodes a program needs without explicitly specifying how the program navigates to those nodes.

XPath is a fourth-generation ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX 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.