How to: Evaluate an XPath Expression
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
You can evaluate XPath expressions with the QuickWatch dialog box. The XPath expression must be valid according to the W3C XPath 1.0 recommendation. The current XSLT context—that is, the self::node()
node in the Locals window—provides the evaluation context for the XPath expression.
The following list describes which functions are supported when evaluating an XPath expression:
Built-in XPath functions are supported.
Built-in XSLT functions are not supported.
User-defined functions are not supported.
Note
The following procedure uses the belowAvg.xsl and books.xml files from the Walkthrough: Debug an XSLT Style Sheet topic.
To evaluate an XPath expression
Insert a breakpoint at the
xsl:if
start tag.Click the Debug XSL button on the XML Editor toolbar.
The debugger starts and breaks on the
xsl:if
tag.Right-click and select QuickWatch.
The QuickWatch dialog box is displayed.
Enter
./price/text()
in the Expression field of the QuickWatch dialog box and click Reevaluate.The price of the current book node appears in the Value box.
Change the XPath expression to
./price/text() < $bookAverage
and click Reevaluate.The Value box shows that the XPath expression evaluates to
true
.