Writing XML with the XmlWriter Class

The XmlWriter class is an abstract class that provides fast, forward-only, noncached output of XML to a file or a stream. You can use the XmlTextWriter class, which derives from XmlWriter, to create and persist XML documents. The advantages of using an XmlTextWriter object over performing output manually using Stream.Write calls or similar are threefold. First, XmlTextWriter will write syntactically correct XML output. Second, XmlTextWriter has powerful support for namespaces, avoiding the need for the user to maintain namespace stacks in a complex document. Third, XmlTextWriter will automatically translate any special characters in text to entities, for example, transforming x < y to x &lt; y.

In this section, ...

Get Microsoft® .NET Compact Framework (Core Reference) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.