XPathNavigator.MoveToFollowing Metodo

Definizione

Sposta il tipo XPathNavigator sull'elemento specificato in base all'ordine con cui è riportato nel documento.

Overload

MoveToFollowing(XPathNodeType, XPathNavigator)

Sposta l'oggetto XPathNavigator sull'elemento seguente dell'enumerazione XPathNodeType specificato, sul limite specificato, nell'ordine dei documenti.

MoveToFollowing(String, String, XPathNavigator)

Sposta l'oggetto XPathNavigator sull'elemento con il nome locale e l'URI dello spazio dei nomi specificati, sul limite specificato, nell'ordine dei documenti.

MoveToFollowing(XPathNodeType)

Sposta l'oggetto XPathNavigator sull'elemento seguente dell'enumerazione XPathNodeType specificato nell'ordine dei documenti.

MoveToFollowing(String, String)

Sposta l'oggetto XPathNavigator sull'elemento con il nome locale e l'URI dello spazio dei nomi specificati nell'ordine dei documenti.

MoveToFollowing(XPathNodeType, XPathNavigator)

Source:
XPathNavigator.cs
Source:
XPathNavigator.cs
Source:
XPathNavigator.cs

Sposta l'oggetto XPathNavigator sull'elemento seguente dell'enumerazione XPathNodeType specificato, sul limite specificato, nell'ordine dei documenti.

public:
 virtual bool MoveToFollowing(System::Xml::XPath::XPathNodeType type, System::Xml::XPath::XPathNavigator ^ end);
public virtual bool MoveToFollowing (System.Xml.XPath.XPathNodeType type, System.Xml.XPath.XPathNavigator? end);
public virtual bool MoveToFollowing (System.Xml.XPath.XPathNodeType type, System.Xml.XPath.XPathNavigator end);
abstract member MoveToFollowing : System.Xml.XPath.XPathNodeType * System.Xml.XPath.XPathNavigator -> bool
override this.MoveToFollowing : System.Xml.XPath.XPathNodeType * System.Xml.XPath.XPathNavigator -> bool
Public Overridable Function MoveToFollowing (type As XPathNodeType, end As XPathNavigator) As Boolean

Parametri

type
XPathNodeType

Oggetto XPathNodeType dell'elemento. Il tipo di nodo XPathNodeType non può essere Attribute o Namespace.

end
XPathNavigator

Oggetto XPathNavigator posizionato in corrispondenza del limite dell'elemento che l'oggetto XPathNavigator corrente non deve superare durante la ricerca dell'elemento seguente.

Restituisce

true se l'oggetto XPathNavigator viene spostato. In caso contrario, false.

Esempio

Nell'esempio seguente, l'oggetto XPathNavigator viene spostato dalla radice del contosoBooks.xml file all'elemento seguente price . Viene eseguito un clone dell'oggetto XPathNavigator usando il Clone metodo . Il clonato XPathNavigator, posizionato sull'elemento price , verrà usato come limite. Le modifiche nella posizione della clonata XPathNavigator non influiscono sull'originale XPathNavigator. L'originale XPathNavigator viene spostato nella radice del contosoBooks.xml file usando il MoveToRoot metodo . Il titolo e il cognome dell'autore vengono recuperati usando il MoveToFollowing metodo e un XPathNodeType oggetto .Text Il MoveToFollowing metodo restituirà true finché non viene raggiunto il limite dell'elemento price .

    XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml");
    XPathNavigator^ navigator = document->CreateNavigator();

    navigator->MoveToFollowing("price", "http://www.contoso.com/books");
    XPathNavigator^ boundary = navigator->Clone();

    navigator->MoveToRoot();

while (navigator->MoveToFollowing(XPathNodeType::Text, boundary))
    {
        Console::WriteLine(navigator->OuterXml);
    }
XPathDocument document = new XPathDocument("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();

navigator.MoveToFollowing("price", "http://www.contoso.com/books");
XPathNavigator boundary = navigator.Clone();

navigator.MoveToRoot();

while (navigator.MoveToFollowing(XPathNodeType.Text, boundary))
{
    Console.WriteLine(navigator.OuterXml);
}
Dim document As XPathDocument = New XPathDocument("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()

navigator.MoveToFollowing("price", "http://www.contoso.com/books")
Dim boundary As XPathNavigator = navigator.Clone()

navigator.MoveToRoot()

While navigator.MoveToFollowing(XPathNodeType.Text, boundary)
    Console.WriteLine(navigator.OuterXml)
End While

Nell'esempio il file contosoBooks.xml viene considerato come input.

<?xml version="1.0" encoding="utf-8" ?>  
<bookstore xmlns="http://www.contoso.com/books">  
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">  
        <title>The Autobiography of Benjamin Franklin</title>  
        <author>  
            <first-name>Benjamin</first-name>  
            <last-name>Franklin</last-name>  
        </author>  
        <price>8.99</price>  
    </book>  
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">  
        <title>The Confidence Man</title>  
        <author>  
            <first-name>Herman</first-name>  
            <last-name>Melville</last-name>  
        </author>  
        <price>11.99</price>  
    </book>  
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">  
        <title>The Gorgias</title>  
        <author>  
            <name>Plato</name>  
        </author>  
        <price>9.99</price>  
    </book>  
</bookstore>  

Commenti

  • Il MoveToFollowing metodo non viene spostato in nodi di attributo o spazio dei nomi. Se il valore del XPathNodeType parametro è Attribute o Namespace, il MoveToFollowing metodo restituisce false e la posizione dell'oggetto XPathNavigator è invariata.

  • Se il XPathNavigator limite passato come parametro non viene posizionato dopo la posizione dell'oggetto corrente XPathNavigator ignorato.

  • Se XPathNavigator il limite passato come parametro è null il nodo seguente successivo con l'oggetto specificato XPathNodeType si trova nell'ordine dei documenti.

  • I MoveToFollowing metodi non possono essere usati per passare a nodi di attributo o spazio dei nomi. Se il XPathNavigator limite passato come parametro viene posizionato su un nodo attributo o spazio dei nomi, equivale al XPathNavigator parametro limite posizionato sul primo nodo figlio dell'elemento padre. Ciò garantisce che l'elemento padre del nodo dell'attributo o dello spazio dei nomi in cui il XPathNavigator parametro limite sia posizionato può essere corrispondente a questo metodo.

  • Se il MoveToFollowing metodo restituisce false, la posizione dell'oggetto XPathNavigator è invariata.

Si applica a

MoveToFollowing(String, String, XPathNavigator)

Source:
XPathNavigator.cs
Source:
XPathNavigator.cs
Source:
XPathNavigator.cs

Sposta l'oggetto XPathNavigator sull'elemento con il nome locale e l'URI dello spazio dei nomi specificati, sul limite specificato, nell'ordine dei documenti.

public:
 virtual bool MoveToFollowing(System::String ^ localName, System::String ^ namespaceURI, System::Xml::XPath::XPathNavigator ^ end);
public virtual bool MoveToFollowing (string localName, string namespaceURI, System.Xml.XPath.XPathNavigator? end);
public virtual bool MoveToFollowing (string localName, string namespaceURI, System.Xml.XPath.XPathNavigator end);
abstract member MoveToFollowing : string * string * System.Xml.XPath.XPathNavigator -> bool
override this.MoveToFollowing : string * string * System.Xml.XPath.XPathNavigator -> bool
Public Overridable Function MoveToFollowing (localName As String, namespaceURI As String, end As XPathNavigator) As Boolean

Parametri

localName
String

Nome locale dell'elemento.

namespaceURI
String

URI dello spazio dei nomi dell'elemento.

end
XPathNavigator

L'oggetto XPathNavigator posizionato in corrispondenza del limite dell'elemento che l'oggetto XPathNavigator corrente non deve superare durante la ricerca dell'elemento seguente.

Restituisce

true se l'oggetto XPathNavigator viene spostato. In caso contrario, false.

Esempio

Nell'esempio seguente, l'oggetto XPathNavigator viene spostato dalla radice del contosoBooks.xml file all'elemento seguente book . Un clone dell'oggetto XPathNavigator viene eseguito usando il Clone metodo e viene spostato dall'elemento all'elemento book seguente first-name . Il clonato XPathNavigator, posizionato sull'elemento first-name , verrà usato come limite. Le modifiche nella posizione della clonata XPathNavigator non influiscono sull'originale XPathNavigator. L'originale XPathNavigator tenta quindi di passare all'elemento seguente price usando il metodo con il MoveToFollowing limite passato come parametro. Questo spostamento ha esito negativo perché l'elemento seguente price supera il limite. L'originale XPathNavigator tenta quindi di passare all'elemento seguente title che è prima del limite usando lo stesso metodo e ha esito positivo.

XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml");
XPathNavigator^ navigator = document->CreateNavigator();

navigator->MoveToFollowing("book", "http://www.contoso.com/books");
XPathNavigator^ boundary = navigator->Clone();
boundary->MoveToFollowing("first-name", "http://www.contoso.com/books");

navigator->MoveToFollowing("price", "http://www.contoso.com/books", boundary);

Console::WriteLine("Position (after boundary): {0}", navigator->Name);
Console::WriteLine(navigator->OuterXml);

navigator->MoveToFollowing("title", "http://www.contoso.com/books", boundary);

Console::WriteLine("Position (before boundary): {0}", navigator->Name);
Console::WriteLine(navigator->OuterXml);
XPathDocument document = new XPathDocument("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();

navigator.MoveToFollowing("book", "http://www.contoso.com/books");
XPathNavigator boundary = navigator.Clone();
boundary.MoveToFollowing("first-name", "http://www.contoso.com/books");

navigator.MoveToFollowing("price", "http://www.contoso.com/books", boundary);

Console.WriteLine("Position (after boundary): {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);

navigator.MoveToFollowing("title", "http://www.contoso.com/books", boundary);

Console.WriteLine("Position (before boundary): {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
Dim document As XPathDocument = New XPathDocument("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()

navigator.MoveToFollowing("book", "http://www.contoso.com/books")
Dim boundary As XPathNavigator = navigator.Clone()
boundary.MoveToFollowing("first-name", "http://www.contoso.com/books")

navigator.MoveToFollowing("price", "http://www.contoso.com/books", boundary)

Console.WriteLine("Position (after boundary): {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)

navigator.MoveToFollowing("title", "http://www.contoso.com/books", boundary)

Console.WriteLine("Position (before boundary): {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)

Nell'esempio il file contosoBooks.xml viene considerato come input.

<?xml version="1.0" encoding="utf-8" ?>  
<bookstore xmlns="http://www.contoso.com/books">  
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">  
        <title>The Autobiography of Benjamin Franklin</title>  
        <author>  
            <first-name>Benjamin</first-name>  
            <last-name>Franklin</last-name>  
        </author>  
        <price>8.99</price>  
    </book>  
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">  
        <title>The Confidence Man</title>  
        <author>  
            <first-name>Herman</first-name>  
            <last-name>Melville</last-name>  
        </author>  
        <price>11.99</price>  
    </book>  
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">  
        <title>The Gorgias</title>  
        <author>  
            <name>Plato</name>  
        </author>  
        <price>9.99</price>  
    </book>  
</bookstore>  

Commenti

  • Se il XPathNavigator limite passato come parametro non viene posizionato dopo la posizione dell'oggetto corrente XPathNavigator ignorato.

  • Se il XPathNavigator parametro limite è null, l'elemento seguente con il nome locale e l'URI dello spazio dei nomi specificato si trova nell'ordine del documento.

  • I MoveToFollowing metodi non possono essere usati per passare a nodi di attributo o spazio dei nomi. Se il XPathNavigator limite passato come parametro viene posizionato su un nodo attributo o spazio dei nomi, equivale al XPathNavigator parametro limite posizionato sul primo nodo figlio dell'elemento padre. Ciò garantisce che l'elemento padre del nodo dell'attributo o dello spazio dei nomi in cui il XPathNavigator parametro limite sia posizionato può essere corrispondente a questo metodo.

  • Se il MoveToFollowing metodo restituisce false, la posizione dell'oggetto XPathNavigator è invariata.

Si applica a

MoveToFollowing(XPathNodeType)

Source:
XPathNavigator.cs
Source:
XPathNavigator.cs
Source:
XPathNavigator.cs

Sposta l'oggetto XPathNavigator sull'elemento seguente dell'enumerazione XPathNodeType specificato nell'ordine dei documenti.

public:
 virtual bool MoveToFollowing(System::Xml::XPath::XPathNodeType type);
public virtual bool MoveToFollowing (System.Xml.XPath.XPathNodeType type);
abstract member MoveToFollowing : System.Xml.XPath.XPathNodeType -> bool
override this.MoveToFollowing : System.Xml.XPath.XPathNodeType -> bool
Public Overridable Function MoveToFollowing (type As XPathNodeType) As Boolean

Parametri

type
XPathNodeType

Oggetto XPathNodeType dell'elemento. Il tipo di nodo XPathNodeType non può essere Attribute o Namespace.

Restituisce

true se l'oggetto XPathNavigator viene spostato. In caso contrario, false.

Esempio

Nell'esempio seguente, l'oggetto XPathNavigator viene spostato dalla radice del contosoBooks.xml file all'elemento seguente bookstore .

    XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml");
    XPathNavigator^ navigator = document->CreateNavigator();

navigator->MoveToFollowing(XPathNodeType::Element);

    Console::WriteLine("Position: {0}", navigator->Name);
    Console::WriteLine(navigator->OuterXml);
XPathDocument document = new XPathDocument("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();

navigator.MoveToFollowing(XPathNodeType.Element);

Console.WriteLine("Position: {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
Dim document As XPathDocument = New XPathDocument("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()

navigator.MoveToFollowing(XPathNodeType.Element)

Console.WriteLine("Position: {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)

Nell'esempio il file contosoBooks.xml viene considerato come input.

<?xml version="1.0" encoding="utf-8" ?>  
<bookstore xmlns="http://www.contoso.com/books">  
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">  
        <title>The Autobiography of Benjamin Franklin</title>  
        <author>  
            <first-name>Benjamin</first-name>  
            <last-name>Franklin</last-name>  
        </author>  
        <price>8.99</price>  
    </book>  
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">  
        <title>The Confidence Man</title>  
        <author>  
            <first-name>Herman</first-name>  
            <last-name>Melville</last-name>  
        </author>  
        <price>11.99</price>  
    </book>  
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">  
        <title>The Gorgias</title>  
        <author>  
            <name>Plato</name>  
        </author>  
        <price>9.99</price>  
    </book>  
</bookstore>  

Commenti

Si applica a

MoveToFollowing(String, String)

Source:
XPathNavigator.cs
Source:
XPathNavigator.cs
Source:
XPathNavigator.cs

Sposta l'oggetto XPathNavigator sull'elemento con il nome locale e l'URI dello spazio dei nomi specificati nell'ordine dei documenti.

public:
 virtual bool MoveToFollowing(System::String ^ localName, System::String ^ namespaceURI);
public virtual bool MoveToFollowing (string localName, string namespaceURI);
abstract member MoveToFollowing : string * string -> bool
override this.MoveToFollowing : string * string -> bool
Public Overridable Function MoveToFollowing (localName As String, namespaceURI As String) As Boolean

Parametri

localName
String

Nome locale dell'elemento.

namespaceURI
String

URI dello spazio dei nomi dell'elemento.

Restituisce

true se l'oggetto XPathNavigator viene spostato. In caso contrario, false.

Esempio

Nell'esempio seguente, l'oggetto XPathNavigator viene spostato dalla radice del contosoBooks.xml file al primo price elemento.

XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml");
XPathNavigator^ navigator = document->CreateNavigator();

navigator->MoveToFollowing("price", "http://www.contoso.com/books");

Console::WriteLine("Position: {0}", navigator->Name);
Console::WriteLine(navigator->OuterXml);
XPathDocument document = new XPathDocument("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();

navigator.MoveToFollowing("price", "http://www.contoso.com/books");

Console.WriteLine("Position: {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
Dim document As XPathDocument = New XPathDocument("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()

navigator.MoveToFollowing("price", "http://www.contoso.com/books")

Console.WriteLine("Position: {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)

Nell'esempio il file contosoBooks.xml viene considerato come input.

<?xml version="1.0" encoding="utf-8" ?>  
<bookstore xmlns="http://www.contoso.com/books">  
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">  
        <title>The Autobiography of Benjamin Franklin</title>  
        <author>  
            <first-name>Benjamin</first-name>  
            <last-name>Franklin</last-name>  
        </author>  
        <price>8.99</price>  
    </book>  
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">  
        <title>The Confidence Man</title>  
        <author>  
            <first-name>Herman</first-name>  
            <last-name>Melville</last-name>  
        </author>  
        <price>11.99</price>  
    </book>  
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">  
        <title>The Gorgias</title>  
        <author>  
            <name>Plato</name>  
        </author>  
        <price>9.99</price>  
    </book>  
</bookstore>  

Commenti

Se il MoveToFollowing metodo restituisce false, la posizione dell'oggetto XPathNavigator è invariata.

Si applica a