Writing Simple Documents

The System.Xml namespace will help you to generate simple XML documents. Many programming languages provide nothing more than basic support for XML, which can make your daily work painful. System.Xml makes many situations much easier because it provides highly sophisticated classes. Many useful features are provided and it's easy to make use of them:

using System;
using System.Xml;

public class Demo
{
        public static void Main(string[] args)
        {
                XmlTextWriter wr =
                        new XmlTextWriter("/tmp/mono.xml", null);

                wr.Formatting = Formatting.Indented;
                wr.Indentation = 3;
                wr.WriteStartDocument();
                wr.Flush();
                wr.Close();
        }
}

First of all, we create an instance of XmlTextWriter. All we have to do is to pass the name of the file we want ...

Get Mono Kick Start 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.