XmlWriter.WriteFullEndElement XmlWriter.WriteFullEndElement XmlWriter.WriteFullEndElement XmlWriter.WriteFullEndElement Method

Definition

Schließt beim Überschreiben in einer abgeleiteten Klasse ein Element und löst den entsprechenden Namespacebereich auf.When overridden in a derived class, closes one element and pops the corresponding namespace scope.

public:
 abstract void WriteFullEndElement();
public abstract void WriteFullEndElement ();
abstract member WriteFullEndElement : unit -> unit
Public MustOverride Sub WriteFullEndElement ()

Ausnahmen

Eine XmlWriter-Methode wurde aufgerufen, bevor ein vorheriger asynchroner Vorgang abgeschlossen wurde.An XmlWriter method was called before a previous asynchronous operation finished. In diesem Fall wird InvalidOperationException mit der Meldung „Es wird bereits ein asynchroner Vorgang ausgeführt“ ausgelöst.In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

Beispiele

Im folgenden Beispiel wird die WriteEndElement und WriteFullEndElement Methoden.The following example uses the WriteEndElement and the WriteFullEndElement methods.

using System;
using System.IO;
using System.Xml;

public class Sample {

  public static void Main() {
  
     // Create a writer to write XML to the console.
     XmlWriterSettings settings = new XmlWriterSettings();
     settings.Indent = true;
     XmlWriter writer = XmlWriter.Create(Console.Out, settings);

     // Write the root element.
     writer.WriteStartElement("order");

     // Write an element with attributes.
     writer.WriteStartElement("item");
     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();

     writer.WriteEndElement();
             
     // Write the XML to file and close the writer
     writer.Close();  
  }
}
Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample
    
  Public Shared Sub Main()

     ' Create a writer to write XML to the console.
     Dim settings As XmlWriterSettings = new XmlWriterSettings()
     settings.Indent = true
     Dim writer As XmlWriter = XmlWriter.Create(Console.Out, settings)
        
     ' Write the root element.
     writer.WriteStartElement("order")
        
     ' Write an element with attributes.
     writer.WriteStartElement("item")
     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()
        
     writer.WriteEndElement()

     ' Write the XML to file and close the writer
     writer.Close()

    End Sub 'Main
End Class 'Sample

Hinweise

Diese Methode schreibt immer den vollständigen End-Tag.This method always writes the full end tag. Dies ist nützlich, bei Elementen, die eine vollständige End-Tag enthalten muss.This is useful when dealing with elements that must include a full end tag. Beispielsweise erwarten Browser HTML-Skriptblöcke geschlossen werden, mit " < /script >".For example, browsers expect HTML script blocks to be closed with "</script>".

Die asynchrone Version dieser Methode finden Sie unter WriteFullEndElementAsync.For the asynchronous version of this method, see WriteFullEndElementAsync.

Gilt für: