Begin with a /
to select the root node
Independent of the context node
/child::PERIODIC_TABLE/child::ATOM
is an XPath expression that selects all ATOM
elements.
/child::PERIODIC_TABLE/child::ATOM[1]
is an XPath expression that selects the first ATOM
element.
/child::PERIODIC_TABLE/child::ATOM/child::SYMBOL
is an XPath expression that selects all SYMBOL
elements.
/child::PERIODIC_TABLE/child::ATOM[ATOMIC_NUMBER="3"]
is an XPath expression that selects Lithium.
/descendant::ATOM[SYMBOL="He"]/child::DENSITY/attribute::UNITS
is an XPath expression that selects the units in which the density of Helium is given.
/child::PERIODIC_TABLE/child::ATOM/child::*
is an XPath expression that selects all the child elements of ATOM
elements.
/descendant::*
is an XPath expression that selects all the elements in the document.
/descendant-or-self::node()
is an XPath expression that selects all non-attribute, non-namespace nodes in the
document.