title: How to save .xml file without overwriting the file and the table? c#
body: <p>I have a program which is made for editing <strong>.xml files</strong>. <strong>I can edit and save .xml files</strong>, writing into the file is working properly, but <strong>when I edit and save another XML Table, it is overwriting the previous one.</strong></p>
  <p>My code:</p>
  <pre><code>            DataTable ds = (DataTable)dataGridView1.DataSource;
              ds.WriteXml(openFileDialog1.FileName);
              saved = true;
              MessageBox.Show(&quot;Successfully saved!&quot;, &quot;Saving.&quot;);
  </code></pre>
  <p>I know why it is happening, the program is saving what is in the dataGridView at the moment of saving.</p>
  <p>I have tried: <code>ds.Merge()</code>, <code>TextWriters</code> various type of <code>Streams</code> and <code>FileModes</code></p>
  <p><em><strong>So how can I save the xml file without overwriting it completely?</strong></em></p>
  <p><em>Example:</em></p>
  <p>This is the file what I have:</p>
  <pre><code>    &lt;catalog&gt;
         &lt;book id=&quot;bk101&quot;&gt;
            &lt;author&gt;Gambardella, Matthew&lt;/author&gt;
            &lt;title&gt;XML Developer's Guide&lt;/title&gt;
            &lt;genre&gt;Computer&lt;/genre&gt;
            &lt;price&gt;44.95&lt;/price&gt;
            &lt;publish_date&gt;2000-10-01&lt;/publish_date&gt;
            &lt;description&gt;An in-depth look at creating applications 
            with XML.&lt;/description&gt;
         &lt;/book&gt;
  &lt;catalog&gt;
  </code></pre>
  <p>But when I edit the file, using another XML Table it gets overwritten, and it will look like this:</p>
  <pre><code>&lt;catalog&gt;
    &lt;plant&gt;
      &lt;name&gt;tulip&lt;/name&gt;
    &lt;/plant&gt;
  &lt;/catalog&gt;
  </code></pre>
  <p><strong>Thanks for any kind of help!</strong></p>
  <p><em>Sorry for bad language.</em></p>