Writing XML to a file

XmlWriter class can be used to write a xml document. The class has several methods like: WriteStartDocument, WriteStartElement, WriteComment, WriteAttributes etc.

    public class XmlWriter : IDisposable
    {
        // const
        const string location = @"c:\temp";

        // privates
        private XmlTextWriter xw;

        // constructor
        public XmlWriter()
        {
            xw = XmlTextWriter(location, System.Text.Encoding.UTF8);
            xw.Formatting = System.Xml.Formatting.Indented;
        }

        // methods
        public void addentrys(string text)
        {
            xw.WriteStartElement("aanvulling");
            xw.WriteString(text);
            xw.WriteEndElement();
        }

        public void Dispose()
        {
            xw.WriteEndElement();
            xw.Close();
        }
    }

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!