Nyelv

XmlTextWriter.WriteFullEndElement Metódus

Definíció

Bezár egy elemet, és a megfelelő névtér hatókörét ugratja ki.

public:
 override void WriteFullEndElement();
public override void WriteFullEndElement();
override this.WriteFullEndElement : unit -> unit
Public Overrides Sub WriteFullEndElement ()

Példák

Az alábbi példa egy tartalom nélküli elemet ír ki. A WriteFullEndElement használatával írja meg a teljes végű elem címkéjét.

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

Megjegyzések

Note

Javasoljuk, hogy a XmlWriter metódus és a XmlWriter.Create osztály használatával hozzon létre XmlWriterSettings példányokat az új funkciók előnyeinek kihasználásához.

Ez a metódus mindig a teljes címkét írja. Ez akkor hasznos, ha olyan elemeket kezel, amelyeknek teljes körű címkét kell tartalmazniuk. A böngészők például azt várják, hogy a HTML-szkriptblokkok "</szkripttel>" lesznek lezárva.

A következőre érvényes: