NewLineOnAttributes Property

XmlWriterSettings.NewLineOnAttributes 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 attributes on a new line.

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

public bool NewLineOnAttributes { get; set; }

Property Value

Type: System.Boolean
true to write attributes on individual lines; otherwise false. The default is false.
NoteNote:

This setting has no effect when the Indent property value is false.

When NewLineOnAttributes is set to true, each attribute is pre-pended with a new line and one extra level of indentation.

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


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();


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft