How to save this string into XML file?
The fact that it’s XML is basically irrelevant. You can save any text to a file very simply with File.WriteAllText: File.WriteAllText(“foo.xml”, xml); Note that you can also specify the encoding, which defaults to UTF-8. So for example, if you want to write a file in plain ASCII: File.WriteAllText(“foo.xml”, xml, Encoding.ASCII);