Export (0) Print
Expand All

XmlWriterSettings.Indent Property

Gets or sets a value indicating whether to indent elements.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

Public Property Indent As Boolean

Property Value

Type: System.Boolean
true to write individual elements on new lines and indent; otherwise, false. The default is false.

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 


       ' 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.WriteElementString("item", "tesing")

         If Not (writer Is Nothing) Then
         End If 
      End Try 

   End Sub  
End Class

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
© 2015 Microsoft