Why XPath?

Refer to the Mini Case Study from Chapter 10. If you look at the order of the elements in the XML file and compare that order with the order in the XHTML output in the screen shot, it is clear that you are transforming the XML data and reordering it. You are not outputting the elements in the order they exist in the input document.

To transform the XML elements the way you want, you need a way of identifying particular parts of the original XML file and choosing only the desired parts to change. This is where XPath comes in. XPath allows you to match patterns of elements and thus identify unambiguously the element(s) you want to work on.

Note

In addition to locating element nodes, XPath allows element attributes, processing instructions, ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 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.