XmlNodeExtensions.XPathSelectSingleNode Method (XmlNode, string, IXmlNamespaceResolver)XmlNodeExtensions.XPathSelectSingleNode Method (XmlNode, String, IXmlNamespaceResolver)XmlNodeExtensions::XPathSelectSingleNode Method (XmlNode^, String^, IXmlNamespaceResolver^)

Evaluates the specified XPath 2.0 expression to select a single node.

Syntax

Public Shared Function XPathSelectSingleNode( _
    node As System.Xml.XmlNode, _
    expression As String, _
    resolver As System.Xml.IXmlNamespaceResolver _
) As System.Xml.XmlNode
public static System.Xml.XmlNode XPathSelectSingleNode(
    System.Xml.XmlNode node,
    string expression,
    System.Xml.IXmlNamespaceResolver resolver
)
public:
static System.Xml::XmlNode^ XPathSelectSingleNode(
    System.Xml::XmlNode^ node, 
    String^ expression, 
    System.Xml::IXmlNamespaceResolver^ resolver
)
 

Parameters

node

Type: System.Xml.XmlNodeSystem.Xml.XmlNodeSystem.Xml::XmlNode^

The XmlNodeXmlNodeXmlNode to use as the context item.

expression

Type: System.StringSystem.StringSystem::String^

A stringStringString representing the XPath 2.0 expression.

resolver

Type: System.Xml.IXmlNamespaceResolverSystem.Xml.IXmlNamespaceResolverSystem.Xml::IXmlNamespaceResolver^

The IXmlNamespaceResolverIXmlNamespaceResolverIXmlNamespaceResolver object used to resolve namespace prefixes in the XPath 2.0 expression.

Return Value

Type: System.Xml.XmlNodeSystem.Xml.XmlNodeSystem.Xml::XmlNode^

The result of the evaluating the XPath 2.0 expression specified; otherwise, null a null reference (Nothing in Visual Basic) nullptr if there are no query results.

Exceptions

ExceptionCondition
ArgumentNullExceptionArgumentNullExceptionArgumentNullExceptionexpression is null a null reference (Nothing in Visual Basic) nullptr or resolver is null a null reference (Nothing in Visual Basic) nullptr.
InvalidCastExceptionInvalidCastExceptionInvalidCastExceptionThe return type was an item which was not a node.
XdmExceptionXdmExceptionXdmExceptionAn error occurred compiling or evaluating the XPath 2.0 expression.

Remarks

If the XPath 2.0 expression returns more than one node the first node is returned.