XmlWriter.Settingsとは? わかりやすく解説

XmlWriter.Settings プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

この XmlWriter インスタンス作成するために使用した XmlWriterSettings オブジェクト取得します

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

Public Overridable ReadOnly
 Property Settings As XmlWriterSettings
Dim instance As XmlWriter
Dim value As XmlWriterSettings

value = instance.Settings
public virtual XmlWriterSettings Settings { get;
 }
public:
virtual property XmlWriterSettings^ Settings {
    XmlWriterSettings^ get ();
}
/** @property */
public XmlWriterSettings get_Settings ()
public function get Settings
 () : XmlWriterSettings

プロパティ
このライタインスタンス作成するために使用した XmlWriterSettings オブジェクト。このライタCreate メソッド使用して作成されなかった場合、このプロパティnull 参照 (Visual Basic では Nothing) を返します

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

XmlWriterSettings クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

System.Xml.XmlWriter.Create メソッド作成されXmlWriter オブジェクトサポートする一連の機能指定します

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

Public NotInheritable Class
 XmlWriterSettings
Dim instance As XmlWriterSettings
public sealed class XmlWriterSettings
public ref class XmlWriterSettings sealed
public final class XmlWriterSettings
public final class XmlWriterSettings
解説解説
使用例使用例

XML ファイル書き込みを行う XmlWriter作成し新しい行にそれぞれの属性書き込む方法の例を次に示します

Dim settings As XmlWriterSettings = New
 XmlWriterSettings()
settings.Indent = true
settings.OmitXmlDeclaration = true
settings.NewLineOnAttributes = true
       
writer = XmlWriter.Create(Console.Out, settings)

writer.WriteStartElement("order")
writer.WriteAttributeString("orderID", "367A54")
writer.WriteAttributeString("date", "2001-05-03")
writer.WriteElementString("price", "19.95")
writer.WriteEndElement()
    
writer.Flush()
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.OmitXmlDeclaration = true;
settings.NewLineOnAttributes = true;
       
writer = XmlWriter.Create(Console.Out, settings);

writer.WriteStartElement("order");
writer.WriteAttributeString("orderID", "367A54");
writer.WriteAttributeString("date", "2001-05-03");
writer.WriteElementString("price", "19.95");
writer.WriteEndElement();
    
writer.Flush();

このサンプル出力は、次のようになります

<order
  orderID="367A54"
  date="2001-05-03">
  <price>19.95</price>
</order>
継承階層継承階層
System.Object
  System.Xml.XmlWriterSettings
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

XmlWriterSettings コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

XmlWriterSettings クラス新しインスタンス初期化します。

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

Dim instance As New XmlWriterSettings
public XmlWriterSettings ()
public:
XmlWriterSettings ()
public XmlWriterSettings ()
public function XmlWriterSettings ()
解説解説

XmlWriterSettingsインスタンス初期プロパティ値を次の表に示します

プロパティ

初期値

CheckCharacters

true

CloseOutput

false

ConformanceLevel

Document

Encoding

Encoding.UTF8

Indent

false

IndentChars

2 個の空白

NewLineChars

\r\n (復帰改行)

NewLineHandling

Replace

NewLineOnAttributes

false

OmitXmlDeclaration

false

使用例使用例

インデントタブ文字使用する XmlWriter オブジェクト作成する例を次に示します

Imports System
Imports System.IO
Imports System.Xml
Imports System.Text
Imports Microsoft.VisualBasic

Public Class Sample 

  Public Shared Sub Main()
 
  
    Dim writer As XmlWriter = Nothing

    Try 

       ' Create an XmlWriterSettings object with the correct options.
 
       Dim settings As XmlWriterSettings =
 New XmlWriterSettings()
       settings.Indent = true
       settings.IndentChars = (ControlChars.Tab)
       settings.OmitXmlDeclaration = true

       ' Create the XmlWriter object and write some content.
       writer = XmlWriter.Create("data.xml", settings)
       writer.WriteStartElement("book")
       writer.WriteElementString("item", "tesing")
       writer.WriteEndElement()
    
       writer.Flush()

      Finally
         If Not (writer Is
 Nothing) Then
            writer.Close()
         End If
      End Try

   End Sub 
End Class 
using System;
using System.IO;
using System.Xml;
using System.Text;

public class Sample {

  public static void Main()
 {
  
    XmlWriter writer = null;

    try {

       // Create an XmlWriterSettings object with the correct options.
 
       XmlWriterSettings settings = new XmlWriterSettings();
       settings.Indent = true;
       settings.IndentChars = ("\t");
       settings.OmitXmlDeclaration = true;

       // Create the XmlWriter object and write some content.
       writer = XmlWriter.Create("data.xml", settings);
       writer.WriteStartElement("book");
       writer.WriteElementString("item", "tesing");
       writer.WriteEndElement();
    
       writer.Flush();

     } 
     finally  {
        if (writer != null)
          writer.Close();
     }
  } 
} 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

XmlWriterSettings プロパティ


XmlWriterSettings メソッド


XmlWriterSettings メンバ

System.Xml.XmlWriter.Create メソッド作成されXmlWriter オブジェクトサポートする一連の機能指定します

XmlWriterSettings データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド XmlWriterSettings XmlWriterSettings クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ OutputMethod XmlWriter 出力シリアル化するために使用するメソッド取得します
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

XmlWriterSettings クラス
System.Xml 名前空間



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

辞書ショートカット

すべての辞書の索引

「XmlWriter.Settings」の関連用語

XmlWriter.Settingsのお隣キーワード
検索ランキング

   

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



XmlWriter.Settingsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS