XmlTextWriter.WriteFullEndElement 메서드

정의

한 요소를 닫고 해당 네임스페이스 범위를 팝합니다.

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

예제

다음 예제에서는 콘텐츠가 없는 요소를 씁니다. WriteFullEndElement를 사용하여 전체 엔드 요소 태그를 작성합니다.

#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

설명

참고

.NET Framework 2.0부터는 메서드와 XmlWriterSettings 클래스를 사용하여 XmlWriter.Create 새 기능을 활용하여 인스턴스를 만드는 XmlWriter 것이 좋습니다.

이 메서드는 항상 전체 끝 태그를 씁니다. 이는 전체 엔드 태그를 포함해야 하는 요소를 처리할 때 유용합니다. 예를 들어 브라우저는 HTML 스크립트 블록이 "</script>"로 닫혀 있어야 합니다.

적용 대상