Share via


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 (Second Edition) (www.w3.org/TR/2000/REC-xml-20001006.html) recommendation and the Namespaces in XML recommendation (www.w3.org/TR/REC-xml-names/).

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.

In This Section

  • 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.