Export (0) Print
Expand All

XmlWriter.Create Method

Creates a new XmlWriter instance.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method Static member Create(Stream) Creates a new XmlWriter instance using the specified stream.
Public method Static member Create(String) Creates a new XmlWriter instance using the specified filename.
Public method Static member Create(StringBuilder) Creates a new XmlWriter instance using the specified StringBuilder.
Public method Static member Create(TextWriter) Creates a new XmlWriter instance using the specified TextWriter.
Public method Static member Create(XmlWriter) Creates a new XmlWriter instance using the specified XmlWriter object.
Public method Static member Create(Stream, XmlWriterSettings) Creates a new XmlWriter instance using the stream and XmlWriterSettings object.
Public method Static member Create(String, XmlWriterSettings) Creates a new XmlWriter instance using the filename and XmlWriterSettings object.
Public method Static member Create(StringBuilder, XmlWriterSettings) Creates a new XmlWriter instance using the StringBuilder and XmlWriterSettings objects.
Public method Static member Create(TextWriter, XmlWriterSettings) Creates a new XmlWriter instance using the TextWriter and XmlWriterSettings objects.
Public method Static member Create(XmlWriter, XmlWriterSettings) Creates a new XmlWriter instance using the specified XmlWriter and XmlWriterSettings objects.
Top

Some of the Create overloads include a settings parameter that accepts an XmlWriterSettings object. You can use this object to:

  • Specify which features you want supported on the created XmlWriter object.

  • Reuse the XmlWriterSettings object to create multiple writer objects. The XmlWriterSettings object is copied and marked read-only for each created writer. Changes to the settings on an XmlWriterSettings instance do not affect existing writers with the same settings. Thus, you can use the same settings to create multiple writers with the same functionality. Or, you can modify the settings on an XmlWriterSettings instance and create a new writer with a different set of features.

  • Add features to an existing XML writer. The Create method can accept another XmlWriter object. The underlying XmlWriter object does not have to be an XML writer created by the static Create method. For example, you can specify a user-defined XML writer to add additional features to.

  • Take full advantage of features such as better conformance checking and compliance to the XML 1.0 recommendation that are available only on XmlWriter objects created by the static Create method.

If you use a Create overload that doesn't accept an XmlWriterSettings object, the following default writer settings are used:

Note Note

Although the .NET Framework includes the XmlTextWriter class, which is a concrete implementation of the XmlWriter class, we recommend that you create XmlWriter instances by using the Create method.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft