System.Xml.XPath.XPathExpression.Compile Method

Compiles the specified XPath expression, with the System.Xml.IXmlNamespaceResolver object specified for namespace resolution, and returns an System.Xml.XPath.XPathExpression object that represents the XPath expression.

Syntax

public static XPathExpression Compile (string xpath, System.Xml.IXmlNamespaceResolver nsResolver)

Parameters

xpath
An XPath expression.
nsResolver
An object that implements the System.Xml.IXmlNamespaceResolver interface for namespace resolution.

Returns

An System.Xml.XPath.XPathExpression object.

Remarks

An XPath expression is evaluated to yield one of the following result types.

Note:

If a user-defined function with an invalid number of arguments (or an unimplemented user-defined function) is specified in the XPath expression, an exception occurs only at run-time. User-defined functions are not checked at compile time and exceptions resulting from user-defined functions occur only if execution evaluates the expression.

Note:

It is not possible to compile a System.Xml.XPath.XPathExpression with a custom context in one step by passing an System.Xml.Xsl.XsltContext, which implements System.Xml.IXmlNamespaceResolver, as an argument to this method. To use a System.Xml.XPath.XPathExpression with a custom context, you must call the erload:System.Xml.XPath.XPathExpression.SetContext method after compiling the expression.

Requirements

Namespace: System.Xml.XPath
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0