XPathNavigator.MoveToFollowing Metode

Definisi

Memindahkan elemen XPathNavigator ke elemen yang ditentukan dalam urutan dokumen.

Overload

Nama Deskripsi
MoveToFollowing(XPathNodeType, XPathNavigator)

XPathNavigator Memindahkan ke elemen berikut dari XPathNodeType yang ditentukan, ke batas yang ditentukan, dalam urutan dokumen.

MoveToFollowing(String, String, XPathNavigator)

XPathNavigator Memindahkan ke elemen dengan nama lokal dan URI namespace yang ditentukan, ke batas yang ditentukan, dalam urutan dokumen.

MoveToFollowing(XPathNodeType)

XPathNavigator Memindahkan ke elemen berikut dari XPathNodeType yang ditentukan dalam urutan dokumen.

MoveToFollowing(String, String)

XPathNavigator Memindahkan ke elemen dengan nama lokal dan namespace URI yang ditentukan dalam urutan dokumen.

MoveToFollowing(XPathNodeType, XPathNavigator)

Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs

XPathNavigator Memindahkan ke elemen berikut dari XPathNodeType yang ditentukan, ke batas yang ditentukan, dalam urutan dokumen.

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

Elemen XPathNodeType . tidak XPathNodeType boleh Attribute atau Namespace.

end
XPathNavigator

Objek XPathNavigator yang diposisikan pada batas elemen yang saat ini XPathNavigator tidak akan bergerak melewati saat mencari elemen berikut.

Mengembalikan

true jika berhasil XPathNavigator dipindahkan; jika tidak, false.

Contoh

Dalam contoh berikut, XPathNavigator dipindahkan dari akar contosoBooks.xml file ke elemen berikut price . Klon XPathNavigator objek dibuat menggunakan Clone metode . Yang dikloning XPathNavigator, diposisikan pada price elemen , akan digunakan sebagai batas. Perubahan dalam posisi kloning XPathNavigator tidak memengaruhi aslinya XPathNavigator. Aslinya XPathNavigator dipindahkan kembali ke akar contosoBooks.xml file menggunakan MoveToRoot metode . Judul dan nama depan dan belakang penulis diambil menggunakan MoveToFollowing metode dan XPathNodeType dari Text. Metode MoveToFollowing akan mengembalikan true sampai price batas elemen tercapai.

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

Contoh mengambil contosoBooks.xml file sebagai 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>

Keterangan

Berlaku untuk

MoveToFollowing(String, String, XPathNavigator)

Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs

XPathNavigator Memindahkan ke elemen dengan nama lokal dan URI namespace yang ditentukan, ke batas yang ditentukan, dalam urutan dokumen.

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

Nama lokal elemen .

namespaceURI
String

URI namespace elemen.

end
XPathNavigator

Objek XPathNavigator yang diposisikan pada batas elemen yang saat ini XPathNavigator tidak akan bergerak melewati saat mencari elemen berikut.

Mengembalikan

true jika berhasil XPathNavigator dipindahkan; jika tidak, false.

Contoh

Dalam contoh berikut, XPathNavigator dipindahkan dari akar contosoBooks.xml file ke elemen berikut book . Klon XPathNavigator objek dibuat menggunakan Clone metode dan dipindahkan dari book elemen ke elemen berikut first-name . Yang dikloning XPathNavigator, diposisikan pada first-name elemen , akan digunakan sebagai batas. Perubahan dalam posisi kloning XPathNavigator tidak memengaruhi aslinya XPathNavigator. Yang asli XPathNavigator kemudian mencoba untuk pindah ke elemen berikut price menggunakan MoveToFollowing metode dengan batas yang diteruskan sebagai parameter. Pemindahan ini gagal karena elemen berikut price berada di luar batas. Yang asli XPathNavigator kemudian mencoba untuk pindah ke elemen berikut title yang sebelum batas menggunakan metode yang sama dan berhasil.

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)

Contoh mengambil contosoBooks.xml file sebagai 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>

Keterangan

  • XPathNavigator Jika batas diteruskan sebagai parameter tidak diposisikan setelah posisi saat ini XPathNavigator diabaikan.

  • XPathNavigator Jika parameter batas adalah null, elemen berikut dengan nama lokal dan URI namespace yang ditentukan terletak dalam urutan dokumen.

  • Metode MoveToFollowing tidak dapat digunakan untuk berpindah ke atribut atau node namespace. XPathNavigator Jika batas yang diteruskan sebagai parameter diposisikan di atas atribut atau node namespace, itu setara dengan XPathNavigator parameter batas yang telah diposisikan pada node anak pertama dari elemen induknya. Ini memastikan bahwa elemen induk dari atribut atau node namespace yang XPathNavigator diposisikan parameter batas dapat dicocokkan dengan metode ini.

  • MoveToFollowing Jika metode mengembalikan false, posisi XPathNavigator tidak berubah.

Berlaku untuk

MoveToFollowing(XPathNodeType)

Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs

XPathNavigator Memindahkan ke elemen berikut dari XPathNodeType yang ditentukan dalam urutan dokumen.

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

Elemen XPathNodeType . tidak XPathNodeType boleh Attribute atau Namespace.

Mengembalikan

true jika berhasil XPathNavigator dipindahkan; jika tidak, false.

Contoh

Dalam contoh berikut, XPathNavigator dipindahkan dari akar contosoBooks.xml file ke elemen berikut bookstore .

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)

Contoh mengambil contosoBooks.xml file sebagai 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>

Keterangan

Berlaku untuk

MoveToFollowing(String, String)

Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs
Sumber:
XPathNavigator.cs

XPathNavigator Memindahkan ke elemen dengan nama lokal dan namespace URI yang ditentukan dalam urutan dokumen.

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

Nama lokal elemen .

namespaceURI
String

URI namespace elemen.

Mengembalikan

true jika berhasil XPathNavigator dipindahkan; jika tidak, false.

Contoh

Dalam contoh berikut, XPathNavigator dipindahkan dari akar contosoBooks.xml file ke elemen pertama price .

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)

Contoh mengambil contosoBooks.xml file sebagai 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>

Keterangan

MoveToFollowing Jika metode mengembalikan false, posisi XPathNavigator tidak berubah.

Berlaku untuk