XmlWriterSettings XmlWriterSettings XmlWriterSettings Constructor

定義

XmlWriterSettings クラスの新しいインスタンスを初期化します。Initializes a new instance of the XmlWriterSettings class.

public:
 XmlWriterSettings();
public XmlWriterSettings ();
Public Sub New ()

次の例では、作成、XmlWriterインデントにタブ文字を使用するオブジェクト。The following example creates an XmlWriter object that uses the TAB character for indentation.

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();
     }
  } 
} 
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 

注釈

次の表のインスタンスの初期プロパティ値XmlWriterSettingsします。The following table shows initial property values for an instance of XmlWriterSettings.

プロパティProperty 初期値Initial Value
Async falsefalse.
CheckCharacters true.true.
CloseOutput false.false.
ConformanceLevel Document.Document.
Encoding Encoding.UTF8.Encoding.UTF8.
Indent falsefalse.
IndentChars 2 つのスペース。Two spaces.
NewLineChars \r\n (キャリッジ リターン、改行します。)\r\n (carriage return, new line).
NewLineHandling ReplaceReplace.
NewLineOnAttributes false.false.
OmitXmlDeclaration false.false.
WriteEndDocumentOnClose truetrue.

適用対象