Extensions::XPathSelectElement Method (XNode^, String^)

 

Selects an XElement using a XPath expression.

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

public:
[ExtensionAttribute]
static XElement^ XPathSelectElement(
	XNode^ node,
	String^ expression
)

Parameters

node
Type: System.Xml.Linq::XNode^

The XNode on which to evaluate the XPath expression.

expression
Type: System::String^

A String that contains an XPath expression.

Return Value

Type: System.Xml.Linq::XElement^

An XElement, or null.

The following example creates a small XML tree and uses XPathSelectElement to select a single element.

No code example is currently available or this language may not be supported.

This example produces the following output:

<Child4>4</Child4>

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