XPathExpression::Compile Method (String^, IXmlNamespaceResolver^)

 

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

Namespace:   System.Xml.XPath
Assembly:  System.Xml (in System.Xml.dll)

public:
static XPathExpression^ Compile(
	String^ xpath,
	IXmlNamespaceResolver^ nsResolver
)

Parameters

xpath
Type: System::String^

An XPath expression.

nsResolver
Type: System.Xml::IXmlNamespaceResolver^

An object that implements the IXmlNamespaceResolver interface for namespace resolution.

Exception Condition
ArgumentException

The XPath expression parameter is not a valid XPath expression.

XPathException

The XPath expression is not valid.

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

System_CAPS_noteNote

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.

System_CAPS_noteNote

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

.NET Framework
Available since 2.0
Silverlight
Available since 4.0
Return to top
Show: