System.Xml.XPath.XPathNavigator.ComparePosition Method

Compares the position of the current System.Xml.XPath.XPathNavigator with the position of the System.Xml.XPath.XPathNavigator specified.

Syntax

public virtual System.Xml.XmlNodeOrder ComparePosition (XPathNavigator nav)

Parameters

nav
The System.Xml.XPath.XPathNavigator to compare against.

Returns

An System.Xml.XmlNodeOrder value representing the comparative position of the two System.Xml.XPath.XPathNavigator objects.

Remarks

The following table describes the System.Xml.XmlNodeOrder enumeration.

System.Xml.XmlNodeOrder.Before

The current node of this System.Xml.XPath.XPathNavigator is before the current node of the supplied System.Xml.XPath.XPathNavigator.

System.Xml.XmlNodeOrder.After

The current node of this System.Xml.XPath.XPathNavigator is after the current node of the supplied System.Xml.XPath.XPathNavigator.

System.Xml.XmlNodeOrder.Same

The two System.Xml.XPath.XPathNavigator objects are positioned on the same node.

System.Xml.XmlNodeOrder.Unknown

The node positions cannot be determined relative to each other in the document order, or null is specified as the System.Xml.XPath.XPathNavigator parameter. This could occur if the two nodes reside in different trees.

The XPathNavigator.ComparePosition(XPathNavigator) method's behavior is dependent on the System.Xml.XPath.XPathNodeType the System.Xml.XPath.XPathNavigator is currently positioned on. When comparing nodes in the XML document, the following rules apply:

Note:

For more information about the XPath data model and details about each of the node types, see section 5 of the W3C XML Path Language (XPath) recommendation located at http://www.w3.org/TR/xpath#data-model.

This method has no effect on the state of the System.Xml.XPath.XPathNavigator.

Note:

Use the XPathNavigator.IsSamePosition(XPathNavigator) method rather than the XPathNavigator.ComparePosition(XPathNavigator) method when possible.

Requirements

Namespace: System.Xml.XPath
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0