Compares the position of the current System.Xml.XPath.XPathNavigator with the position of the System.Xml.XPath.XPathNavigator specified.
- nav
- The System.Xml.XPath.XPathNavigator to compare against.
An System.Xml.XmlNodeOrder value representing the comparative position of the two System.Xml.XPath.XPathNavigator objects.
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:
XPathNodeType.Element nodes: These nodes are returned in document order from the source document.
XPathNodeType.Namespace nodes: These nodes may be returned in document order and are always before the XPathNodeType.Attribute nodes of the parent element.
XPathNodeType.Attribute nodes: These nodes may be returned in document order. They always come after the XPathNodeType.Namespace nodes and before any child nodes of the parent node.
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.
Use the XPathNavigator.IsSamePosition(XPathNavigator) method rather than the XPathNavigator.ComparePosition(XPathNavigator) method when possible.