Editar

Compartir a través de


XPathNavigator.ComparePosition(XPathNavigator) Method

Definition

Compares the position of the current XPathNavigator with the position of the XPathNavigator specified.

public:
 virtual System::Xml::XmlNodeOrder ComparePosition(System::Xml::XPath::XPathNavigator ^ nav);
public virtual System.Xml.XmlNodeOrder ComparePosition (System.Xml.XPath.XPathNavigator? nav);
public virtual System.Xml.XmlNodeOrder ComparePosition (System.Xml.XPath.XPathNavigator nav);
abstract member ComparePosition : System.Xml.XPath.XPathNavigator -> System.Xml.XmlNodeOrder
override this.ComparePosition : System.Xml.XPath.XPathNavigator -> System.Xml.XmlNodeOrder
Public Overridable Function ComparePosition (nav As XPathNavigator) As XmlNodeOrder

Parameters

nav
XPathNavigator

The XPathNavigator to compare against.

Returns

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

Remarks

The following table describes the XmlNodeOrder enumeration.

XmlNodeOrder Description
Before The current node of this XPathNavigator is before the current node of the supplied XPathNavigator.
After The current node of this XPathNavigator is after the current node of the supplied XPathNavigator.
Same The two XPathNavigator objects are positioned on the same node.
Unknown The node positions cannot be determined relative to each other in the document order, or null is specified as the XPathNavigator parameter. This could occur if the two nodes reside in different trees.

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

  • Element nodes: These nodes are returned in document order from the source document.

  • Namespace nodes: These nodes may be returned in document order and are always before the Attribute nodes of the parent element.

  • Attribute nodes: These nodes may be returned in document order. They always come after the Namespace nodes and before any child nodes of the parent node.

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.

This method has no effect on the state of the XPathNavigator.

Note

Use the IsSamePosition method rather than the ComparePosition method when possible.

Applies to

See also