Export (0) Print
Expand All

XmlWriterSettings Constructor

Initializes a new instance of the XmlWriterSettings class.

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

public XmlWriterSettings()

The following table shows initial property values for an instance of XmlWriterSettings.

Property

Initial Value

CheckCharacters

true.

CloseOutput

false.

ConformanceLevel

Document.

Encoding

Encoding.UTF8.

Indent

false.

IndentChars

Two spaces.

NewLineChars

\r\n (carriage return, new line).

NewLineHandling

Replace.

NewLineOnAttributes

false.

OmitXmlDeclaration

false.

For more information and code examples, see XML Data.



StringBuilder output = new StringBuilder();

    XmlWriterSettings settings = new XmlWriterSettings();
    settings.Indent = true;
    settings.OmitXmlDeclaration = true;
    settings.NewLineOnAttributes = true;

    using (XmlWriter writer = 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();
}

OutputTextBlock.Text = output.ToString();


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft