XmlWriter.WriteFullEndElement 메서드

정의

파생 클래스에서 재정의되면 한 요소를 닫고 해당 네임스페이스 범위를 팝합니다.

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

예외

이전 비동기 작업이 완료되기 전에 XmlWriter 메서드가 호출되었습니다. 이 경우 “비동기 작업이 이미 진행 중입니다.” 메시지를 나타내며 InvalidOperationException이 throw됩니다.

예제

다음 예제에서는 메서드와 메서드를 WriteFullEndElement 사용합니다WriteEndElement.

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.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
End Class

설명

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

이 메서드의 비동기 버전은 다음을 참조하세요 WriteFullEndElementAsync.

적용 대상