Writing
Writing XML documentation is greatly simplified with the System.XML class library. The particular class used in this section is the XMLTextWriter class. It has numerous convenience methods that make producing XML documents a snap. The .NET Frameworks documentation lists all the available methods for the XMLTextWriter class. Listing 18.1 shows how to write XML data to a file.
Listing 18.1. Writing an XML Document
/// <summary> /// write XML data to a file /// </summary> void WriteXML() { XmlTextWriter xr = new XmlTextWriter(fileName, null); xr.Formatting = Formatting.Indented; xr.Indentation = 4; xr.WriteStartDocument(); xr.WriteComment("Holds data for the MoneyTalk program."); xr.WriteStartElement("MoneyTalk"); xr.WriteElementString("Talk", ... |
Get C# Unleashed 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.