System.Xml.XPath.XPathNavigator.Evaluate Method

Evaluates the System.Xml.XPath.XPathExpression and returns the typed result.

Syntax

public virtual object Evaluate (XPathExpression expr)

Parameters

expr
An System.Xml.XPath.XPathExpression 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 returns a number after converting the Price/text() node to a number and multiplying the value by 10.

Example

XPathExpression expr = nav.Compile("Price/text()*10");
nav.Evaluate(expr);
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