System.Xml.XmlWriter.Create Method

Creates a new System.Xml.XmlWriter instance using the specified stream.

Syntax

public static XmlWriter Create (System.IO.Stream output)

Parameters

output
The stream to which you want to write. The System.Xml.XmlWriter writes XML 1.0 text syntax and appends it to the specified stream.

Returns

An System.Xml.XmlWriter object.

Remarks

When you use this overload, an System.Xml.XmlWriterSettings object with the following default settings is used to create the XML writer:

XmlWriterSettings.CheckCharacters

true

XmlWriterSettings.CloseOutput

false

XmlWriterSettings.ConformanceLevel

ConformanceLevel.Document

XmlWriterSettings.Encoding

System.Text.Encoding.UTF8

XmlWriterSettings.Indent

false

XmlWriterSettings.IndentChars

Two spaces

XmlWriterSettings.NamespaceHandling

NamespaceHandling.Default (no removal)

XmlWriterSettings.NewLineChars

\r\n (carriage return, new line)

XmlWriterSettings.NewLineHandling

NewLineHandling.Replace

XmlWriterSettings.NewLineOnAttributes

false

XmlWriterSettings.OmitXmlDeclaration

false

XmlWriterSettings.OutputMethod

XmlOutputMethod.Xml

XmlWriterSettings.WriteEndDocumentOnClose

true

If you want to specify the features to support on the created writer, use an overload that takes an System.Xml.XmlWriterSettings object as one of its arguments, and pass in an System.Xml.XmlWriterSettings object with your custom settings.

Also, XmlWriter always writes a Byte Order Mark (BOM) to the underlying data stream; however, some streams must not have a BOM. To omit the BOM, create a new System.Xml.XmlWriterSettings object and set the Encoding property to be a new System.Text.UTF8Encoding object with the Boolean value in the constructor set to false.

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0