Saving Formatted XML

Earlier in the chapter, I mentioned that the WriteXml method is used to persist the XML representation of a DataSet and that the GetXml method is used to simply retrieve that XML in a String object. Since then, you've seen how to control the structure of serialized XML via mapping columns to XML node types, how to specify which columns to omit, and how to define hierarchical relationships between elements. At this point, it's time to turn our attention to the issue of controlling the format of the XML when it's persisted.

You can use the members of the XmlWriter class as well as the XmlWriteMode enumeration to exercise the utmost control over the way the XML serialized. Consider the following code to control the indentation ...

Get Extending MFC Applications with the .NET Framework 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.