append xml file using xmlwriter
<p>Thanks for the earlier suggestion to use "XMLWriter" ,everytime it creates new xml file so i used xmldoc to load the xml file then append in that file,here is my code but it throws exception saying "This document already has a 'DocumentElement' node."</p>

<pre><code>  //Append to xml file 


            XmlDocument doc = new XmlDocument();
            doc.Load(@"c:\\test.xml");
            using (XmlWriter xmlWrite = doc.CreateNavigator().AppendChild())
            {
                 xmlWrite.WriteStartElement("image name=",Name);
                xmlWrite.WriteElementString("width", widthValue[1]);
                xmlWrite.WriteElementString("Height", heightValue[1]);
                xmlWrite.WriteElementString("file-size", FileSizeValue[1]);
                xmlWrite.WriteElementString("file-format", FileFormatValue[1]);
                xmlWrite.WriteElementString("resolution", ResolutionValue[1]);
                xmlWrite.Close();
            }
</code></pre>

<p>here is my sample test.xml </p>

<pre><code>    &lt;job-metadata&gt;
    &lt;slug&gt;730s_Sales/CupWinner_0111&lt;/slug&gt;
    &lt;locations&gt;Africa&lt;/locations&gt;
    &lt;primary-location&gt;Africa&lt;/primary-location&gt;
    &lt;reporter&gt;Leigh Sales&lt;/reporter&gt;
    &lt;genre&gt;Current&lt;/genre&gt;
    &lt;copyright&gt;CBS&lt;/copyright&gt;
    &lt;autopublish&gt;true&lt;/autopublish&gt; 
&lt;/job-metadata&gt;
</code></pre>

<p>Am trying to append in the xml like below</p>

<pre><code> &lt;job-metadata&gt;
    &lt;slug&gt;730s_Sales/CupWinner_0111&lt;/slug&gt;
    &lt;locations&gt;Africa&lt;/locations&gt;
    &lt;primary-location&gt;Africa&lt;/primary-location&gt;
    &lt;reporter&gt;Leigh Sales&lt;/reporter&gt;
    &lt;genre&gt;Current&lt;/genre&gt;
    &lt;copyright&gt;CBS&lt;/copyright&gt;
    &lt;autopublish&gt;true&lt;/autopublish&gt; 
- &lt;image name="557684_20111101-730s_SalesCupWinner_0111_80x60.jpg"&gt;
        &lt;width&gt;80&lt;/width&gt;
        &lt;height&gt;60&lt;/height&gt;
        &lt;file-size&gt;7045&lt;/file-size&gt;
        &lt;file-format&gt;JPEG Baseline&lt;/file-format&gt;
        &lt;resolution&gt;72&lt;/resolution&gt;
        &lt;custom-name&gt;newsthumbnail&lt;/custom-name&gt;
    &lt;/image&gt;
&lt;/job-metadata&gt;
</code></pre>

<p>Thanks in Advance</p>
