Compound Location Paths
The XPath expressions you’ve seen so far—element names,
@
plus an attribute name, /
, comment(
)
, text( )
, and processing-instruction( )
—are all single
location steps. You can combine these with the
forward slash to move around the hierarchy from the
matched node to other nodes. Furthermore, you can use a period to
refer to the context node, a double period to refer to the parent
node, and a double forward slash to refer to descendants of the
context node. With the exception of //
, these are all similar to Unix shell
syntax for navigating a hierarchical filesystem.
Get XML in a Nutshell, 3rd 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.