Navigating XML Data with XPath Axes

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XPath Developer's Guide

Navigating XML Data Using XPath Axes

An axis in XPath is similar to an axis in a traditional two or three dimensional chart or graph. It tells the XPath-aware processor which direction to look, up, down, or sideways in a document tree, starting from a given point of origin—the context node. Using an axis as part of a location step is:

axisname::nodetest

Where axisname is one of the built-in axes defined by the XPath specification, selected from the list below, and nodetest indicates which node(s) along that axis are of interest. For example:

child::*

indicates to select all children of the context node, while

/child::*

is to select all children of the root node, which is made the context node by virtue of the opening slash.

Using an axis in an XPath expression extends your options in navigating through the document tree. A traditional unidirectional path, such as to a file on a Web server, is similar to the following:

/rootfolder/subfolder/subsubfolder

unlike this sort of path or a traditional charting application with its X, Y, and Z axes, XPath provides you with a rich variety of axes. Each XPath axis consist of a tree-like structure to the context node.

For more information, see Use XPath Axes to Navigate through XML Data.