Gets or sets a value indicating whether to omit an XML declaration.
Assemblies: System.Xml (in System.Xml.dll)
System.Xml.ReaderWriter (in System.Xml.ReaderWriter.dll)
This property only applies to XmlWriter instances that output text content; otherwise, this setting is ignored.
If is set to false, The XML declaration is written automatically
The following example writes an XML fragment to a memory stream.
Dim settings As XmlWriterSettings = New XmlWriterSettings() settings.OmitXmlDeclaration = true settings.ConformanceLevel = ConformanceLevel.Fragment settings.CloseOutput = false ' Create the XmlWriter object and write some content. Dim strm as MemoryStream = new MemoryStream() Dim writer As XmlWriter = XmlWriter.Create(strm, settings) writer.WriteElementString("orderID", "1-456-ab") writer.WriteElementString("orderID", "2-36-00a") writer.Flush() writer.Close() ' Do additonal processing on the stream.