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.
.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