Eck's Path: Using XPath for Easy Data Extraction
In the last section, we showed how to use DOM4J to read data from an XML document. We used the element and elementText methods to extract data from items in the tree. There is another way of traversing a DOM4J tree, using an expression language called XPath . With XPath, we can follow a path from the root of the document to any point in the tree by using a shorthand expression that looks something like a Unix directory path. Let's use the purchase order XML as an example. We can find the terms of delivery by following the Order (root) element to its DeliveryTerms child element and to the ...
Get Wicked Cool Java 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.