Export (0) Print
Expand All

XmlWriterSettings.NewLineOnAttributes Property

Note: This property is new in the .NET Framework version 2.0.

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 */
public boolean get_NewLineOnAttributes ()

/** @property */
public void set_NewLineOnAttributes (boolean value)

public function get NewLineOnAttributes () : boolean

public function set NewLineOnAttributes (value : boolean)

Property Value

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.

The following example creates an XmlWriter that writes to an XML file and writes each attribute on a new line.

XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.OmitXmlDeclaration = true;
settings.NewLineOnAttributes = true;
       
writer = XmlWriter.Create(Console.Out, settings);

writer.WriteStartElement("order");
writer.WriteAttributeString("orderID", "367A54");
writer.WriteAttributeString("date", "2001-05-03");
writer.WriteElementString("price", "19.95");
writer.WriteEndElement();
	
writer.Flush();

The sample produces the following output:

<order
  orderID="367A54"
  date="2001-05-03">
  <price>19.95</price>
</order>

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft