Gets or sets a value indicating whether to indent elements.
Assembly: System.Xml (in System.Xml.dll)
This property only applies to XmlWriter instances that output text content; otherwise, this setting is ignored.
The elements are indented as long as the element does not contain mixed content. Once the WriteString or WriteWhitespace method is called to write out a mixed element content, the XmlWriter stops indenting. The indenting resumes once the mixed content element is closed.
The following example creates an XmlWriter object that uses the TAB character for indentation.
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
.NET FrameworkSupported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
XNA FrameworkSupported in: 3.0, 2.0, 1.0
Portable Class LibrarySupported in: Portable Class Library
Supported in: Windows Phone 8.1
Supported in: Windows Phone Silverlight 8.1
Supported in: Windows Phone Silverlight 8