It is possible to create an XML data structure and then save that data directly to a text file using the XMLDocument.Save() method; this recipe illustrates how.
Creating XML text files – saving XML directly to text files with XMLDocument.Save()
How to do it...
To save XML data to text files directly, perform the following steps:
- Create a new C# PlayerXMLWriter script class:
using System.Xml;
using System.IO;
public class PlayerXMLWriter {
private string filePath;
private XmlDocument xmlDoc;
private XmlElement elRoot;
public PlayerXMLWriter(string filePath) {
this.filePath = filePath;
xmlDoc = new XmlDocument();
if(File.Exists (filePath...