XmlWriterSettings.IndentChars XmlWriterSettings.IndentChars XmlWriterSettings.IndentChars XmlWriterSettings.IndentChars Property

정의

들여쓰기에 사용할 문자열을 가져오거나 설정합니다.Gets or sets the character string to use when indenting. 이 설정은 Indent 속성이 true로 설정된 경우에 사용됩니다.This setting is used when the Indent property is set to true.

public:
 property System::String ^ IndentChars { System::String ^ get(); void set(System::String ^ value); };
public string IndentChars { get; set; }
member this.IndentChars : string with get, set
Public Property IndentChars As String

속성 값

들여쓰기에 사용할 문자열입니다.The character string to use when indenting. 이 속성에 설정할 수 있는 문자열 값에는 제한이 없습니다.This can be set to any string value. 그러나 XML을 올바르게 유지하려면 공백 문자, 탭, 캐리지 리턴 또는 줄 바꿈 같은 유효한 공백 문자만 지정해야 합니다.However, to ensure valid XML, you should specify only valid white space characters, such as space characters, tabs, carriage returns, or line feeds. 기본값은 공백 두 개입니다.The default is two spaces.

예외

IndentChars에 할당된 값이 null인 경우The value assigned to the IndentChars is null.

예제

다음 예제에서는 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 

설명

이 속성에만 적용 됩니다 XmlWriter 인스턴스 텍스트 콘텐츠를 출력 하는이 설정이 무시 되 고, 그렇지 않으면입니다.This property only applies to XmlWriter instances that output text content; otherwise, this setting is ignored. XmlWriter 들여쓰기 문자가 인해 XML이 잘못 된 경우 예외를 throw 합니다.The XmlWriter throws an exception if the indent characters would result in invalid XML.

적용 대상