XmlTextWriter.WriteFullEndElement Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Cierra un elemento y extrae el correspondiente ámbito de espacio de nombres.
public:
override void WriteFullEndElement();
public override void WriteFullEndElement ();
override this.WriteFullEndElement : unit -> unit
Public Overrides Sub WriteFullEndElement ()
Ejemplos
En el ejemplo siguiente se escribe un elemento sin contenido. Usa WriteFullEndElement para escribir la etiqueta de elemento final completa.
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
//Create a writer to write XML to the console.
XmlTextWriter^ writer = nullptr;
writer = gcnew 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();
}
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
Comentarios
Nota:
A partir de .NET Framework 2.0, se recomienda crear XmlWriter instancias mediante el XmlWriter.Create método y la XmlWriterSettings clase para aprovechar las nuevas funcionalidades.
Este método siempre escribe la etiqueta de extremo completo. Esto resulta útil cuando se trabaja con elementos que deben incluir una etiqueta de extremo completa. Por ejemplo, los exploradores esperan que los bloques de script HTML se cierren con "</script>".