XmlTextWriter.WriteWhitespace メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlTextWriter.WriteWhitespace メソッドの意味・解説 

XmlTextWriter.WriteWhitespace メソッド

指定した空白書き込みます

名前空間: System.Xml
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

Public Overrides Sub WriteWhitespace
 ( _
    ws As String _
)
Dim instance As XmlTextWriter
Dim ws As String

instance.WriteWhitespace(ws)
public override void WriteWhitespace (
    string ws
)
public:
virtual void WriteWhitespace (
    String^ ws
) override
public void WriteWhitespace (
    String ws
)
public override function WriteWhitespace (
    ws : String
)

パラメータ

ws

空白文字文字列

例外例外
解説解説
使用例使用例

WriteWhitespace メソッド使用してファイル書式設定する方法制御する例を次に示します

Option Strict
Option Explicit

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample
    
    Public Shared Sub Main()
        ' Create the writer.
        Dim writer As XmlTextWriter = Nothing
        writer = New XmlTextWriter("ws.html",
 Nothing)
        
        ' Write an element (this one is the root).
        writer.WriteStartElement("p")
        
        ' Write the xml:space attribute.
        writer.WriteAttributeString("xml", "space",
 Nothing, "preserve")
        
        ' Verify that xml:space is set properly.
        If writer.XmlSpace = XmlSpace.Preserve Then
            Console.WriteLine("xmlspace is correct!")
        End If 
        ' Write out the HTML elements.  Insert white space
        ' between 'something' and 'Big'.
        writer.WriteString("something")
        writer.WriteWhitespace("  ")
        writer.WriteElementString("b", "B")
        writer.WriteString("ig")
        
        ' Write the root end element.
        writer.WriteEndElement()
        
        ' Write the XML to file and close the writer.
        writer.Close()
    End Sub 'Main
End Class 'Sample
using System;
using System.IO;
using System.Xml;

public class Sample
{  
  public static void Main()
  {
    // Create the writer.
    XmlTextWriter writer = null;
    writer = new XmlTextWriter ("ws.html", null);

    // Write an element (this one is the root).
    writer.WriteStartElement("p");

    // Write the xml:space attribute.
    writer.WriteAttributeString("xml", "space", null,
 "preserve");

    // Verify that xml:space is set properly.
    if (writer.XmlSpace == XmlSpace.Preserve)
      Console.WriteLine("xmlspace is correct!");

    // Write out the HTML elements.  Insert white space
    // between 'something' and 'Big'
    writer.WriteString("something");
    writer.WriteWhitespace("  ");
    writer.WriteElementString("b", "B");
    writer.WriteString("ig");

    // Write the root end element.
    writer.WriteEndElement();
             
    // Write the XML to file and close the writer.
    writer.Close();  
  }
}
#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   // Create the writer.
   XmlTextWriter^ writer = nullptr;
   writer = gcnew XmlTextWriter( "ws.html", nullptr );
   
   // Write an element (this one is the root).
   writer->WriteStartElement( "p" );
   
   // Write the xml:space attribute.
   writer->WriteAttributeString( "xml", "space", nullptr,
 "preserve" );
   
   // Verify that xml:space is set properly.
   if ( writer->XmlSpace == XmlSpace::Preserve )
      Console::WriteLine( "xmlspace is correct!" );

   
   // Write out the HTML elements.  Insert white space
   // between 'something' and 'Big'
   writer->WriteString( "something" );
   writer->WriteWhitespace( "  " );
   writer->WriteElementString( "b", "B" );
   writer->WriteString( "ig" );
   
   // Write the root end element.
   writer->WriteEndElement();
   
   // Write the XML to file and close the writer.
   writer->Close();
}

import System.*;
import System.IO.*;
import System.Xml.*;

public class Sample
{
    public static void main(String[]
 args)
    {
        // Create the writer. 
        XmlTextWriter writer = null;
        writer = new XmlTextWriter("ws.html", null);

        // Write an element (this one is the root).
        writer.WriteStartElement("p");

        // Write the xml:space attribute.
        writer.WriteAttributeString("xml", "space", null,
 "preserve");

        // Verify that xml:space is set properly.
        if ( writer.get_XmlSpace().Equals(XmlSpace.Preserve))
 {
            Console.WriteLine("xmlspace is correct!");
        }

        // Write out the HTML elements.  Insert white space
        // between 'something' and 'Big'
        writer.WriteString("something");
        writer.WriteWhitespace("  ");
        writer.WriteElementString("b", "B");
        writer.WriteString("ig");

        // Write the root end element.
        writer.WriteEndElement();

        // Write the XML to file and close the writer.
        writer.Close();
    } //main
} //Sample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からXmlTextWriter.WriteWhitespace メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からXmlTextWriter.WriteWhitespace メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からXmlTextWriter.WriteWhitespace メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

XmlTextWriter.WriteWhitespace メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



XmlTextWriter.WriteWhitespace メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS