Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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:
© 2017 Microsoft