When to Use XmlWriter
You should use XmlWriter when you want to output
data from your program to a file or Stream in XML
format. Since XmlTextWriter’s
constructors take a Stream, a filename, and a
TextWriter, respectively, you can output to any
common I/O target.
In addition, any .NET class that takes an
XmlWriter to output its data as XML may use any
XmlWriter subclass. This means, for example, that
you may output a DOM tree in any of the supported formats. You may
also send data to any other format, as long as an
XmlWriter exists to produce that format.
Like XmlReader, you can extend
XmlWriter to produce output in alternative XML
syntaxes—or even syntaxes that have nothing whatsoever to do
with XML, as long as the XmlWriter interface is
supported.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access