OmitXmlDeclaration Property

XmlWriterSettings.OmitXmlDeclaration Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets a value indicating whether to write an XML declaration.

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

'Declaration
Public Property OmitXmlDeclaration As Boolean

Property Value

Type: System.Boolean
true to omit the XML declaration; otherwise false. The default is false, an XML declaration is written.

This property only applies to XmlWriter instances that output text content; otherwise, this setting is ignored.

If OmitXmlDeclaration is set to false, The XML declaration is written automatically

The XML declaration is always written if ConformanceLevel is set to Document, even if OmitXmlDeclaration is set to true.

The XML declaration is never written if ConformanceLevel is set to Fragment. You can call WriteProcessingInstruction to explicitly write out an XML declaration.


Dim output As New StringBuilder()

Dim settings As New XmlWriterSettings()
settings.Indent = True
settings.OmitXmlDeclaration = True
settings.NewLineOnAttributes = True

Using writer As XmlWriter = XmlWriter.Create(output, settings)

    writer.WriteStartElement("order")
    writer.WriteAttributeString("orderID", "367A54")
    writer.WriteAttributeString("date", "2001-05-03")
    writer.WriteElementString("price", "19.95")
    writer.WriteEndElement()

    writer.Flush()
End Using
OutputTextBlock.Text = output.ToString()


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft