다음을 통해 공유


XmlWriterSettings 생성자

정의

XmlWriterSettings 클래스의 새 인스턴스를 초기화합니다.

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

예제

다음 예제에서는 들여쓰기를 위해 TAB 문자를 사용하는 개체를 만듭니다 XmlWriter .

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.IO
Imports System.Xml
Imports System.Text

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합니다.

속성 초기 값
Async false.
CheckCharacters true.
CloseOutput false.
ConformanceLevel Document.
Encoding Encoding.UTF8.
Indent false.
IndentChars 두 개의 공백입니다.
NewLineChars \r\n (캐리지 리턴, 새 줄).
NewLineHandling Replace.
NewLineOnAttributes false.
OmitXmlDeclaration false.
WriteEndDocumentOnClose true.

적용 대상