FileMode.append adding a new node everytime rather than a child node
<p>The C# code is as follows. I have created an xml at the first entry and then adding nodes to the xml using <code>.append</code> property.</p>

<pre><code>XmlSerializer xs = new XmlSerializer(typeof(DataClass));
if (!File.Exists("Data.xml"))
{
    using (FileStream fs = new FileStream("Data.xml", FileMode.Create))
    {
        xs.Serialize(fs, data);
        fs.Close();
        fs.Dispose();
        MessageBox.Show("Data loaded to the xml");
    }
}
else if (File.Exists("Data.xml"))
{
    using (FileStream fs = new FileStream("Data.xml", FileMode.Append))
    {
        xs.Serialize(fs, data);
        fs.Close();
        fs.Dispose();
        MessageBox.Show("Data loaded to the xml");
    }
}
</code></pre>

<p>This results in an xml like following. It makes a new node for every entry.<br/>
Is there anywhere by which I can add a main tag to the xml because I later need to load the data to a data grid view(the xml needs to be well formed) and also sub nodes.</p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;DataClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;pathI&gt;D:\POC\Input\1&lt;/pathI&gt;
    &lt;pathO&gt;D:\POC\Output&lt;/pathO&gt;
    &lt;prefix&gt;1_&lt;/prefix&gt;
    &lt;frequency&gt;10&lt;/frequency&gt;
&lt;/DataClass&gt;
&lt;?xml version="1.0"?&gt;
&lt;DataClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;pathI&gt;D:\POC\Input\2&lt;/pathI&gt;
    &lt;pathO&gt;D:\POC\Output&lt;/pathO&gt;
    &lt;prefix&gt;2_&lt;/prefix&gt;
    &lt;frequency&gt;20&lt;/frequency&gt;
&lt;/DataClass&gt;
</code></pre>

<p>whereas what I want is :</p>

<pre><code>&lt;?xml version="1.0"?&gt;--- node tag just once and not with every entry
&lt;Data&gt;--- a main tag open
    &lt;DataClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
        &lt;pathI&gt;D:\POC\Input\1&lt;/pathI&gt;
        &lt;pathO&gt;D:\POC\Output&lt;/pathO&gt;
        &lt;prefix&gt;1_&lt;/prefix&gt;
        &lt;frequency&gt;10&lt;/frequency&gt;
    &lt;/DataClass&gt;
    &lt;DataClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
        &lt;pathI&gt;D:\POC\Input\2&lt;/pathI&gt;
        &lt;pathO&gt;D:\POC\Output&lt;/pathO&gt;
        &lt;prefix&gt;2_&lt;/prefix&gt;
        &lt;frequency&gt;20&lt;/frequency&gt;
    &lt;/DataClass&gt;
&lt;/Data&gt;-- main tag closing
</code></pre>
