次の方法で共有


XmlTextWriter.WriteFullEndElement メソッド

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

Overrides Public Sub WriteFullEndElement()
[C#]
public override void WriteFullEndElement();
[C++]
public: void WriteFullEndElement();
[JScript]
public override function WriteFullEndElement();

解説

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

使用例

[Visual Basic, C#, C++] 内容を含まない要素を書き込む例を次に示します。ここでは、WriteFullEndElement を使用して、完全な終了要素タグを書き込みます。

 
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 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 'Main
End Class 'Sample

[C#] 
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();  
  }
}

[C++] 
#using <mscorlib.dll>
#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 = 0;
     writer = new XmlTextWriter (Console::Out);

     //Use indentation for readability.
     writer->Formatting = Formatting::Indented;
        
     //Write an element (this one is the root).
     writer->WriteStartElement(S"order");

     //Write some attributes.
     writer->WriteAttributeString(S"date", S"2/19/01");
     writer->WriteAttributeString(S"orderID", S"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();  
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

XmlTextWriter クラス | XmlTextWriter メンバ | System.Xml 名前空間