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



