XPath Basics
XPath expressions navigate and retrieve XML content similar to traversing a file system’s directory structure, except that XPath works on an XML document tree (also called XML DOM tree).
In XPath, the root node of an XML document is defined as a slash (/). Then, a location path, which is another slash (/) along with the element’s name, steps down the XML DOM tree and selects the specified XML element. For example, the XPath expression /contact returns the <contact> element. The /contact/first_name returns the <first_name> element, which is a child element of <contact>.
The most important type of XPath expressions is the location path, which consists of a sequence of location steps. Each step has three components: an axis, a node ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access