XPathNavigator.ComparePosition(XPathNavigator) Método

Definição

Compara a posição do XPathNavigator atual com a posição do XPathNavigator especificado.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

Parâmetros

nav
XPathNavigator

O XPathNavigator com o qual comparar.The XPathNavigator to compare against.

Retornos

XmlNodeOrder

Um valor XmlNodeOrder que representa a posição de comparação dos dois objetos XPathNavigator.An XmlNodeOrder value representing the comparative position of the two XPathNavigator objects.

Comentários

A tabela a seguir descreve a XmlNodeOrder enumeração.The following table describes the XmlNodeOrder enumeration.

XmlNodeOrderXmlNodeOrder DescriçãoDescription
Before O nó atual disso XPathNavigator é antes do nó atual do fornecido XPathNavigator .The current node of this XPathNavigator is before the current node of the supplied XPathNavigator.
After O nó atual disso XPathNavigator é após o nó atual do fornecido XPathNavigator .The current node of this XPathNavigator is after the current node of the supplied XPathNavigator.
Same Os dois XPathNavigator objetos são posicionados no mesmo nó.The two XPathNavigator objects are positioned on the same node.
Unknown As posições de nó não podem ser determinadas em relação umas às outras na ordem do documento ou null são especificadas como o XPathNavigator parâmetro.The node positions cannot be determined relative to each other in the document order, or null is specified as the XPathNavigator parameter. Isso poderá ocorrer se os dois nós residirem em árvores diferentes.This could occur if the two nodes reside in different trees.

O ComparePosition comportamento do método depende do XPathNodeType que XPathNavigator está posicionado no momento.The ComparePosition method's behavior is dependent on the XPathNodeType the XPathNavigator is currently positioned on. Ao comparar nós no documento XML, as seguintes regras se aplicam:When comparing nodes in the XML document, the following rules apply:

  • Element Nós: esses nós são retornados na ordem do documento do documento de origem.Element nodes: These nodes are returned in document order from the source document.

  • Namespace Nós: esses nós podem ser retornados na ordem do documento e sempre são antes dos Attribute nós do elemento pai.Namespace nodes: These nodes may be returned in document order and are always before the Attribute nodes of the parent element.

  • Attribute Nós: esses nós podem ser retornados na ordem do documento.Attribute nodes: These nodes may be returned in document order. Eles sempre vêm após os Namespace nós e antes de quaisquer nós filho do nó pai.They always come after the Namespace nodes and before any child nodes of the parent node.

Observação

Para obter mais informações sobre o modelo de dados XPath e detalhes sobre cada um dos tipos de nó, consulte a seção 5 da recomendação do W3C XML Path Language (XPath) .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.

Esse método não tem efeito sobre o estado do XPathNavigator .This method has no effect on the state of the XPathNavigator.

Observação

Use o IsSamePosition método, em vez do ComparePosition método, quando possível.Use the IsSamePosition method rather than the ComparePosition method when possible.

Aplica-se a

Confira também