Microsoft XML Core Services (MSXML) 4.0 - XPath Reference

XPath Syntax

XML Path Language (XPath) uses a declarative notation rather than a procedural one. Each expression developed from this notation describes the types of nodes to match based on the hierarchical relationship between the nodes. For example, the expression "book/author" means find the author elements contained in the book elements.

This notation enables you to query an XML tree as a hierarchy of nodes. The syntax mimics the syntax used by URLS to navigate through folders and files. However, instead of specifying navigation through a logical hierarchy of folders, XPath expressions navigate through a hierarchy of nodes in the XML tree. The following table summarizes some of the analogous features between URLs and XPath expressions.

URLs XPath expressions
Hierarchy comprised of folders and files in a file system. Hierarchy comprised of elements and other nodes in an XML document.
Files at each level have unique names. URLs always identify a single file. Element names at each level might not be unique. XPath expressions identify a set of all the matching elements.
Evaluated relative to a particular folder, called the "current folder." Evaluated relative to a particular node called the "context" for the expression.

This section covers the syntax of XML Path Language (XPath) expressions, including the following:

Topics in this section use the Sample XML File for XPath Syntax (inventory.xml).

XPath also support namespaces and data types. Namespace prefixes can be included in expressions so that the matching operations can check for specific namespace prefixes.