Dataset WriteXML places rows added to dataset outside of main nodes
-
I have a dataset that I read from an xml file using
DataSet.ReadXml(fs);
I then add to the dataset and rewrite the xml file using the following:DataRow newrow = mf.quotesDataSet.Tables["quote"].NewRow(); newrow["thequote"] = quoteInput.Text; newrow["speaker"] = speakerInput.Text; newrow["origin"] = originInput.Text; newrow["image"] = "test.jpg"; mf.quotesDataSet.Tables["quote"].Rows.Add(newrow); mf.quotesDataSet.WriteXml(fw);
It does add the data, however, it adds it outside the main xml hierarchy. For example, instead of:<rss> <channel> <quote><thequote>text</thequote></quote> <quote><thequote>text</thequote></quote> <quote><thequote>new text</thequote></quote> </channel> </rss>
it writes to the file as:<rss> <channel> <quote><thequote>text</thequote></quote> <quote><thequote>text</thequote></quote> </channel> </rss> <quote><thequote>new text</thequote></quote>
how do I make the added rows to the dataset write into the proper hierarchy?