XmlWriterSettings.IndentChars プロパティ
アセンブリ: System.Xml (system.xml.dll 内)
構文Dim instance As XmlWriterSettings Dim value As String value = instance.IndentChars instance.IndentChars = value
/** @property */ public String get_IndentChars () /** @property */ public void set_IndentChars (String value)
インデント処理を行うときに使用する文字列。これには任意の文字列値を設定できます。ただし、有効な XML にするには、空白、タブ、復帰、ライン フィードなどの有効な空白文字だけを指定する必要があります。既定値は 2 個の空白です。
解説このプロパティは、テキストの内容を出力する、XmlWriter のインスタンスにのみ適用されます。それ以外の場合、この設定は無視されます。インデント文字によって無効な XML になる場合は、XmlWriter が例外をスローします。
使用例インデントにタブ文字を使用する 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(); } } }
プラットフォームWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照Weblioに収録されているすべての辞書からXmlWriterSettings.IndentChars プロパティを検索する場合は、下記のリンクをクリックしてください。
全ての辞書からXmlWriterSettings.IndentChars プロパティ
を検索
- XmlWriterSettings.IndentChars プロパティのページへのリンク