XmlWriter.WriteEndElement XmlWriter.WriteEndElement XmlWriter.WriteEndElement XmlWriter.WriteEndElement Method

정의

파생 클래스에서 재정의되면 한 요소를 닫고 해당 네임스페이스 범위를 팝합니다.When overridden in a derived class, closes one element and pops the corresponding namespace scope.

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

예외

이로 인해 XML 문서가 잘못되는 경우This results in an invalid XML document.

또는-or-

이전 비동기 작업이 완료되기 전에 XmlWriter 메서드가 호출되었습니다.An XmlWriter method was called before a previous asynchronous operation finished. 이 경우 “비동기 작업이 이미 진행 중입니다.” 메시지를 나타내며 InvalidOperationException이 throw됩니다.In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

예제

다음 예제에서는 합니다 WriteEndElement 하며 WriteFullEndElement 메서드.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

설명

짧은 끝 태그 요소에 콘텐츠가 없는 경우 "/ >" 작성 됩니다. 그렇지 않은 경우 전체 끝 태그를 작성 됩니다.If the element contains no content, a short end tag "/>" is written; otherwise, a full end tag is written.

참고

사용 하는 경우는 XmlWriter XML 요소 및 특성을 출력 하는 메서드를 호출 하기 전에 기록 되지 것입니다는 Close 메서드.When you use the XmlWriter methods to output XML, the elements and attributes will not be written until you call the Close method. 예를 들어, 채우는 XmlWriter를 사용 하는 경우는 XmlDocument닫을 때까지는 XmlWriter, 작성 된 요소 및 대상 문서에 특성을 확인할 수 없습니다.For example, if you are using the XmlWriter to populate an XmlDocument, until you close the XmlWriter, you will not be able to observe the written elements and attributes in the target document.

이 메서드의 비동기 버전을 참조 하세요. WriteEndElementAsync합니다.For the asynchronous version of this method, see WriteEndElementAsync.

적용 대상