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

Using XPath Expressions to Select Nodes

XML Path Language (XPath)is a language used to create expressions that can address parts of an XML document. XPath expressions can also manipulate strings, numbers, and Booleans, and can select a set of nodes in the document. XPath is used by both XSLT and XML Pointer Language (XPointer), and models an XML document as a tree of nodes of different types, including element, attribute, and text. XPath expressions identify these nodes in the XML document based on their types, names, and values, and on the relationship of a node to other nodes in the document. An XPath expression yields one of the following basic objects.

For example, suppose you want to find <author> elements that have a period attribute with the value "classical", and that are contained in the <authors> element at the document root. This query can be expressed with the following XPath expression.

/authors/author[@period='classical']

These expressions are a core part of XSLT transformations, which associate the expression results with templates to create a new XML document. Expressions using the XPath syntax can also be performed directly against the XML Document Object Model (DOM).

An important type of XPath expression is a location path, which is an expression that selects a set of nodes relative to the context node. The result of evaluating a location path is a node-set containing the selected nodes.

For more information about XPath, see the XPath Developer's Guide.

See Also

XPath Syntax | Template-Driven Transformations | Defining Match Patterns in <xsl:template>

Other Resources Other Resources

XML Path Language (XPath) Version 1.0