XmlTextWriter.WriteFullEndElement メソッド

定義

1 つの要素を閉じ、対応する名前空間スコープをポップします。

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 以降では、 メソッドと クラスを使用してXmlWriter.Createインスタンスを作成XmlWriterXmlWriterSettings、新しい機能を利用することをお勧めします。

このメソッドは常に、完全な終了タグを書き込みます。 これは、完全終了タグを含める必要がある要素を処理する場合に便利です。 たとえば、ブラウザーでは、HTML スクリプト ブロックが "/script>"< で閉じられることが想定されています。

適用対象