XmlTextWriter.WriteFullEndElement Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Fecha um elemento e abre o respetivo âmbito do espaço de nomes.
public:
override void WriteFullEndElement();
public override void WriteFullEndElement();
override this.WriteFullEndElement : unit -> unit
Public Overrides Sub WriteFullEndElement ()
Exemplos
O exemplo seguinte escreve um elemento sem conteúdo. Utiliza o WriteFullEndElement para escrever a tag final de elemento completa.
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
//Create a writer to write XML to the console.
XmlTextWriter writer = null;
writer = new XmlTextWriter (Console.Out);
//Use indentation for readability.
writer.Formatting = Formatting.Indented;
//Write an element (this one is the root).
writer.WriteStartElement("order");
//Write some attributes.
writer.WriteAttributeString("date", "2/19/01");
writer.WriteAttributeString("orderID", "136A5");
//Write a full end element. Because this element has no
//content, calling WriteEndElement would have written a
//short end tag '/>'.
writer.WriteFullEndElement();
//Write the XML to file and close the writer
writer.Close();
}
}
Option Explicit
Option Strict
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
'Create a writer to write XML to the console.
Dim writer As XmlTextWriter = Nothing
writer = New XmlTextWriter(Console.Out)
'Use indentation for readability.
writer.Formatting = Formatting.Indented
'Write an element (this one is the root).
writer.WriteStartElement("order")
'Write some attributes.
writer.WriteAttributeString("date", "2/19/01")
writer.WriteAttributeString("orderID", "136A5")
'Write a full end element. Because this element has no
'content, calling WriteEndElement would have written a
'short end tag '/>'.
writer.WriteFullEndElement()
'Write the XML to file and close the writer
writer.Close()
End Sub
End Class
Observações
Note
Recomendamos que crie instâncias XmlWriter usando o método XmlWriter.Create e a classe XmlWriterSettings para aproveitar a nova funcionalidade.
Este método escreve sempre a tag final completa. Isto é útil quando se trata de elementos que devem incluir uma tag final completa. Por exemplo, os navegadores esperam que os blocos de scripts HTML sejam fechados com "</script>".