<%@ page language="C#" masterpagefile="~/templates/Documentation.master" inherits="Page" pagetitle="Examples of XPath Expression Results" keywords="Examples of XPath Expression Results"%>

Examples of XPath Expression Results

Table 97 provides examples of XPath expression results:

Expression
Result
/a 
Returns the document element of the document if it is an a element
/a/b 
Returns all b elements that are immediate children of the document element, which is the a element
//a 
Returns all a elements in the document
//a/b 
Returns all b elements that are immediate children of a elements that are anywhere in the document
a or ./a 
Returns all a elements that are immediate children of the context node
a/b 
Returns all b elements that are immediate children of a elements that are immediate children of the context node
a//b 
Returns all b elements that descend from a elements that are immediate children of the context node
.//a 
Returns all a elements in the document tree branch that starts with the context node
../a 
Returns all a elements in the document tree branch that are children of the parent node of the context node.
Table 97. XPath Expression Results