Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

XmlWriterSettings Class

Specifies a set of features to support on the XmlWriter object created by the XmlWriter.Create method.

System.Object
  System.Xml.XmlWriterSettings

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)
public sealed class XmlWriterSettings

The XmlWriterSettings type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360XmlWriterSettingsInitializes a new instance of the XmlWriterSettings class.
Top
  NameDescription
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360CheckCharactersGets or sets a value indicating whether to do character checking.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360CloseOutputGets or sets a value indicating whether the XmlWriter should also close the underlying stream or TextWriter when the Close method is called.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360ConformanceLevelGets or sets the level of conformance which the XmlWriter complies with.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360EncodingGets or sets the text encoding to use.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360IndentGets or sets a value indicating whether to indent elements.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360IndentCharsGets or sets the character string to use when indenting. This setting is used when the Indent property is set to true.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360NamespaceHandlingGets or sets the NamespaceHandling enumeration used to specify whether to remove duplicate namespace declarations in the XmlWriter. For the duplicate namespace to be removed, the prefix and the namespace have to match.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360NewLineCharsGets or sets the character string to use for line breaks.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360NewLineHandlingGets or sets a value indicating whether to normalize line breaks in the output.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360NewLineOnAttributesGets or sets a value indicating whether to write attributes on a new line.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360OmitXmlDeclarationGets or sets a value indicating whether to write an XML declaration.
Top
  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360CloneCreates a copy of the XmlWriterSettings instance.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360Equals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360FinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ResetResets the members of the settings class to their default values.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ToStringReturns a string that represents the current object. (Inherited from Object.)
Top

In the Microsoft .NET Framework 2.0 release, the Create method is the preferred mechanism for obtaining XmlWriter instances. The Create method uses the XmlWriterSettings class to specify which features to implement in the created XmlWriter object.

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.