https://docs.microsoft.com/en-us/dotnet/csharp/

Read, Modify, Write XML

1
2
3
4
5
6
7
8
9
10
11
12
13
// read from file
XmlDocument xml = new XmlDocument();
xml.Load("input.xml");

// Make changes to the document.
XmlNode node = xml.DocumentElement.SelectSingleNode("/settings");
...

// write to file
using(XmlTextWriter xtw = new XmlTextWriter("output.xml", Encoding.UTF8)) {
xtw.Formatting = Formatting.Indented; // optional, if you want it to look nice
xml.WriteContentTo(xtw);
}
Reference: