6
Answers

Saving New Data into XML using C#

Ask a question
Ika AJ

Ika AJ

14y
2.7k
1
Hi, 

I've an application that needs saving data from datagrid into an XML file. 

Currently, it is working only half way coz the file keeps saving the data to the original file. Which means, it is appended to the bottom of the .XML but it repeats the root element. 

I'ld like to eliminate this problem, but couldn't go about it. 
Any suggestion?

I think my current code is a little low-level, so hopefully, there's a more efficient method.xml_before.jpg


Thanks, 
Ika



P.S: I've inserted screen shots of the before and after of the .xml file when new data is inserted. 

******code.jpg 
xml_before.jpg
xml_after.jpg


Answers (6)