XmlReader.ReadEndElement Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Verifica se o nó de conteúdo atual é uma marca de término e avança o leitor para o próximo nó.
public:
virtual void ReadEndElement();
public virtual void ReadEndElement();
abstract member ReadEndElement : unit -> unit
override this.ReadEndElement : unit -> unit
Public Overridable Sub ReadEndElement ()
Exceções
O nó atual não é uma marca final ou se XML incorreto é encontrado no fluxo de entrada.
Um XmlReader método foi chamado antes de uma operação assíncrona anterior ser concluída. Nesse caso, InvalidOperationException é lançada com a mensagem "Uma operação assíncrona já está em andamento".
Exemplos
O exemplo a seguir exibe o conteúdo de texto de cada elemento.
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
O exemplo usa o book3.xml arquivo.
<book>
<title>Pride And Prejudice</title>
<price>19.95</price>
</book>