Writing a Custom XML Writer

As we’ve seen, an XML writer is a .NET Framework class that specializes in writing out XML text. Because there is just one flavor of XML, the need for customized versions of XmlTextWriter is extremely low. However, a lot of documents and objects out there might take significant advantage of an ad hoc, specialized, and seamless XML serialization class.

In the .NET Framework, all the XML files being used—from ADO.NET Diff­Gram objects to Web .config files—are written using XML writers. (ADO.NET DataSet objects are always remoted and serialized in a special XML format called the DiffGram; see Chapter 10.) In addition, the XML serializer saves and restores .NET Framework objects to and from XML documents. (I’ll cover ...

Get Applied XML Programming for Microsoft® .NET 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.