XmlReader.ReadEndElement Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Vérifie que le nœud de contenu actuel est une balise de fin et avance le lecteur vers le nœud suivant.
public:
virtual void ReadEndElement();
public virtual void ReadEndElement();
abstract member ReadEndElement : unit -> unit
override this.ReadEndElement : unit -> unit
Public Overridable Sub ReadEndElement ()
Exceptions
Le nœud actuel n’est pas une balise de fin ou si le code XML incorrect est rencontré dans le flux d’entrée.
Une XmlReader méthode a été appelée avant la fin d’une opération asynchrone précédente. Dans ce cas, InvalidOperationException est levée avec le message « Une opération asynchrone est déjà en cours ».
Exemples
L’exemple suivant affiche le contenu texte de chaque élément.
using (XmlReader reader = XmlReader.Create("book3.xml")) {
// Parse the XML document. ReadString is used to
// read the text content of the elements.
reader.Read();
reader.ReadStartElement("book");
reader.ReadStartElement("title");
Console.Write("The content of the title element: ");
Console.WriteLine(reader.ReadString());
reader.ReadEndElement();
reader.ReadStartElement("price");
Console.Write("The content of the price element: ");
Console.WriteLine(reader.ReadString());
reader.ReadEndElement();
reader.ReadEndElement();
}
Using reader As XmlReader = XmlReader.Create("book3.xml")
' Parse the XML document. ReadString is used to
' read the text content of the elements.
reader.Read()
reader.ReadStartElement("book")
reader.ReadStartElement("title")
Console.Write("The content of the title element: ")
Console.WriteLine(reader.ReadString())
reader.ReadEndElement()
reader.ReadStartElement("price")
Console.Write("The content of the price element: ")
Console.WriteLine(reader.ReadString())
reader.ReadEndElement()
reader.ReadEndElement()
End Using
L’exemple utilise le book3.xml fichier.
<book>
<title>Pride And Prejudice</title>
<price>19.95</price>
</book>