Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CreateNavigator Method (XNode, XmlNameTable)
Collapse the table of content
Expand the table of content

Extensions.CreateNavigator Method (XNode, XmlNameTable)

Creates an XPathNavigator for an XNode. The XmlNameTable enables more efficient XPath expression processing.

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

public static XPathNavigator CreateNavigator(
	this XNode node,
	XmlNameTable nameTable


Type: System.Xml.Linq.XNode

An XNode that can process an XPath query.

Type: System.Xml.XmlNameTable

A XmlNameTable to be used by XPathNavigator.

Return Value

Type: System.Xml.XPath.XPathNavigator
An XPathNavigator that can process XPath queries.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type XNode. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

You cannot edit the XML tree using the XPathNavigator that is returned by this method. The CanEdit property returns false.

You cannot create an XPathNavigator for a XDocumentType node. Document types do not participate in the XPath data model.

Namespace declarations are reported from left to right. In contrast, for XmlDocument namespaces are reported from right to left. This is conformant behavior because namespace declarations are not ordered in the XPath data model.

The method MoveToId is not supported for navigators that are returned by this method.

If you use an XmlNameTable with this method to create the XPathNavigator, you will get better performance when evaluating XPath expressions.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft