This documentation is archived and is not being maintained.

Writing XML with the XmlWriter

The XmlWriter class is an abstract base class that provides a forward-only, write-only, non-cached way of generating XML streams. It can be used to build XML documents that conform to the W3C Extensible Markup Language (XML) 1.0 (fourth edition) recommendation and the Namespaces in XML recommendation.

The XmlWriter enables you to:

  • Verify that the characters are legal XML characters and that element and attribute names are valid XML names.

  • Verify that the XML document is well-formed.

  • Encode binary bytes as Base64, or BinHex, and write out the resulting text.

  • Pass values using common language runtime types rather than strings. This allows avoid having to manually perform value conversions.

  • Write multiple documents to one output stream.

  • Write valid names, qualified names, and name tokens.

New Features in the XmlWriter Class

Describes changes to the XmlWriter class.

Using the XmlWriter

Describes how to create XmlWriter objects, write typed data, and other common XmlWriter usage.

XML Documents and Data

Provides an overview to a comprehensive and integrated set of classes that work with XML documents and data in the .NET Framework.