System.Xml.XPath.XPathNavigator.Evaluate Method

Evaluates the specified XPath expression and returns the typed result.

Syntax

public virtual object Evaluate (string xpath)

Parameters

xpath
A string representing an XPath expression that can be evaluated.

Returns

The result of the expression (Boolean, number, string, or node set). This maps to bool, double, string, or System.Xml.XPath.XPathNodeIterator objects respectively.

Remarks

The following C# code converts the Price/text() node to a number, multiplies it by 10, and returns the resulting value.

Example

nav.Evaluate("Price/text()*10");
Note:

The XPath position() and last() functions, unless used as a predicate in a location step, require a reference to a node set in order to be evaluated. In this case, you must use the overload which takes an System.Xml.XPath.XPathNodeIterator as an argument; otherwise, position() and last() return 0.

This method has no effect on the state of the System.Xml.XPath.XPathNavigator.

Requirements

Namespace: System.Xml.XPath
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0