XPathNavigator.MoveToFollowing Methode

Definition

Verschiebt das XPathNavigator zum angegebenen Element in der Dokumentreihenfolge.

Überlädt

Name Beschreibung
MoveToFollowing(XPathNodeType, XPathNavigator)

Verschiebt das XPathNavigator folgende Element des XPathNodeType angegebenen Elements in die angegebene Begrenzungsreihenfolge.

MoveToFollowing(String, String, XPathNavigator)

Verschiebt das XPathNavigator Element mit dem angegebenen lokalen Namen und namespace-URI in die angegebene Grenze in der Dokumentreihenfolge.

MoveToFollowing(XPathNodeType)

Verschiebt das XPathNavigator folgende Element der XPathNodeType angegebenen Dokumentreihenfolge.

MoveToFollowing(String, String)

Verschiebt das XPathNavigator Element mit dem lokalen Namen und dem Namespace-URI, der in der Dokumentreihenfolge angegeben ist.

MoveToFollowing(XPathNodeType, XPathNavigator)

Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs

Verschiebt das XPathNavigator folgende Element des XPathNodeType angegebenen Elements in die angegebene Begrenzungsreihenfolge.

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

Parameter

type
XPathNodeType

Das XPathNodeType Element. Dies XPathNodeType kann nicht sein Attribute oder Namespace.

end
XPathNavigator

Das XPathNavigator Objekt, das sich an der Elementgrenze befindet, an die der Aktuelle XPathNavigator beim Suchen nach dem folgenden Element nicht verschoben wird.

Gibt zurück

true wenn das XPathNavigator Verschieben erfolgreich war; falseandernfalls .

Beispiele

Im folgenden Beispiel wird die XPathNavigator Datei aus dem Stamm der contosoBooks.xml Datei in das folgende price Element verschoben. Ein Klon des XPathNavigator Objekts wird mit der Clone Methode erstellt. Der geklonte XPathNavigator, auf dem price Element positionierte, wird als Grenze verwendet. Änderungen an der Position des geklonten XPathNavigator Elements wirken sich nicht auf das Original XPathNavigatoraus. Das Original XPathNavigator wird mithilfe contosoBooks.xml der Methode zurück in den Stamm der MoveToRoot Datei verschoben. Der Titel und der Vor- und Nachname des Autors werden mithilfe der MoveToFollowing Methode und eines XPathNodeType von Textabgerufen. Die MoveToFollowing Methode gibt "true" zurück, bis die price Elementgrenze erreicht ist.

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

Im Beispiel wird die contosoBooks.xml Datei als Eingabe verwendet.

<?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>

Hinweise

  • Die MoveToFollowing Methode wird nicht zu Attribut- oder Namespaceknoten verschoben. Wenn der XPathNodeType Parameterwert oder Attribute-wert istNamespace, gibt die MoveToFollowing Methode zurückfalse, und die Position der Datei XPathNavigator ist unverändert.

  • Wenn die XPathNavigator als Parameter übergebene Grenze nicht nach der Position des aktuellen XPathNavigator Parameters positioniert wird, wird sie ignoriert.

  • Wenn XPathNavigator die Als Parameter null übergebene Grenze der nächste Knoten mit dem angegebenen XPathNodeType Knoten ist, befindet sich in der Dokumentreihenfolge.

  • Die MoveToFollowing Methoden können nicht verwendet werden, um zu Attribut- oder Namespaceknoten zu wechseln. Wenn die XPathNavigator als Parameter übergebene Grenze über einem Attribut oder Namespaceknoten positioniert wird, entspricht sie dem Grenzparameter, der XPathNavigator auf dem ersten untergeordneten Knoten des übergeordneten Elements positioniert wurde. Dadurch wird sichergestellt, dass das übergeordnete Element des Attributs oder Namespaceknotens, auf dem der XPathNavigator Begrenzungsparameter positioniert ist, von dieser Methode abgeglichen werden kann.

  • Wenn die MoveToFollowing Methode zurückgegeben wird false, ist die Position der Methode XPathNavigator unverändert.

Gilt für:

MoveToFollowing(String, String, XPathNavigator)

Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs

Verschiebt das XPathNavigator Element mit dem angegebenen lokalen Namen und namespace-URI in die angegebene Grenze in der Dokumentreihenfolge.

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

Parameter

localName
String

Der lokale Name des Elements.

namespaceURI
String

Der Namespace-URI des Elements.

end
XPathNavigator

Das XPathNavigator Objekt, das sich an der Elementgrenze befindet, an die der Aktuelle XPathNavigator beim Suchen nach dem folgenden Element nicht verschoben wird.

Gibt zurück

true wenn das XPathNavigator Verschieben erfolgreich war; falseandernfalls .

Beispiele

Im folgenden Beispiel wird die XPathNavigator Datei aus dem Stamm der contosoBooks.xml Datei in das folgende book Element verschoben. Ein Klon des XPathNavigator Objekts wird mithilfe der Clone Methode erstellt und vom book Element in das folgende first-name Element verschoben. Der geklonte XPathNavigator, auf dem first-name Element positionierte, wird als Grenze verwendet. Änderungen an der Position des geklonten XPathNavigator Elements wirken sich nicht auf das Original XPathNavigatoraus. Das Original XPathNavigator versucht dann, mithilfe der Methode mit der price als Parameter übergebenen Grenze zum folgenden MoveToFollowing Element zu wechseln. Diese Verschiebung schlägt fehl, da das folgende price Element über die Grenze hinausgeht. Das Original XPathNavigator versucht dann, zum folgenden title Element zu wechseln, das sich vor der Grenze mit derselben Methode befindet und erfolgreich ist.

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)

Im Beispiel wird die contosoBooks.xml Datei als Eingabe verwendet.

<?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>

Hinweise

  • Wenn die XPathNavigator als Parameter übergebene Grenze nicht nach der Position des aktuellen XPathNavigator Parameters positioniert wird, wird sie ignoriert.

  • Wenn der XPathNavigator Grenzparameter lautet null, befindet sich das folgende Element mit dem lokalen Namen und dem angegebenen Namespace-URI in der Dokumentreihenfolge.

  • Die MoveToFollowing Methoden können nicht verwendet werden, um zu Attribut- oder Namespaceknoten zu wechseln. Wenn die XPathNavigator als Parameter übergebene Grenze über einem Attribut oder Namespaceknoten positioniert wird, entspricht sie dem Grenzparameter, der XPathNavigator auf dem ersten untergeordneten Knoten des übergeordneten Elements positioniert wurde. Dadurch wird sichergestellt, dass das übergeordnete Element des Attributs oder Namespaceknotens, auf dem der XPathNavigator Begrenzungsparameter positioniert ist, von dieser Methode abgeglichen werden kann.

  • Wenn die MoveToFollowing Methode zurückgegeben wird false, ist die Position der Methode XPathNavigator unverändert.

Gilt für:

MoveToFollowing(XPathNodeType)

Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs

Verschiebt das XPathNavigator folgende Element der XPathNodeType angegebenen Dokumentreihenfolge.

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

Parameter

type
XPathNodeType

Das XPathNodeType Element. Dies XPathNodeType kann nicht sein Attribute oder Namespace.

Gibt zurück

true wenn das XPathNavigator Verschieben erfolgreich war; falseandernfalls .

Beispiele

Im folgenden Beispiel wird die XPathNavigator Datei aus dem Stamm der contosoBooks.xml Datei in das folgende bookstore Element verschoben.

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)

Im Beispiel wird die contosoBooks.xml Datei als Eingabe verwendet.

<?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>

Hinweise

Gilt für:

MoveToFollowing(String, String)

Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs
Quelle:
XPathNavigator.cs

Verschiebt das XPathNavigator Element mit dem lokalen Namen und dem Namespace-URI, der in der Dokumentreihenfolge angegeben ist.

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

Parameter

localName
String

Der lokale Name des Elements.

namespaceURI
String

Der Namespace-URI des Elements.

Gibt zurück

true wenn das XPathNavigator Verschieben erfolgreich war; falseandernfalls .

Beispiele

Im folgenden Beispiel wird die XPathNavigator Datei aus dem Stamm der contosoBooks.xml Datei in das erste price Element verschoben.

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)

Im Beispiel wird die contosoBooks.xml Datei als Eingabe verwendet.

<?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>

Hinweise

Wenn die MoveToFollowing Methode zurückgegeben wird false, ist die Position der Methode XPathNavigator unverändert.

Gilt für: