- Home /
Question by
stfarless · Mar 16, 2017 at 08:23 PM ·
xmlloading file
Duplicate an XML Document (with a different name)
I want to have a master version of certain xml files (kept in the resources folder), and an editable version. I have some lengthy code which transfers information line by line, but I was wondering if the following would effectively duplicate the document:
//Load Master file from resources
TextAsset oldTextDoc = (TextAsset)Resources.Load (fileName + "Master", typeof(TextAsset));
if (oldTextDoc == null)
Debug.LogError ("File " + fileName + "Master could not be found");
//create new xml document
XmlDocument newXMLDoc = new XmlDocument ();
newXMLDoc.Load (new StringReader (oldTextDoc.text));
//Save new file in appropriate location
StreamWriter outStream = System.IO.File.CreateText(basePath+fileName+".xml");
newXMLDoc.Save (outStream);
outStream.Close ();
Thank you!
Comment
Your answer
Follow this Question
Related Questions
Where should I store text files I intend to edit? 1 Answer
A node in a childnode? 1 Answer
Load file on Android 1 Answer
Accessing FBX Animation Sub Clips 1 Answer
Load data made in editor? 1 Answer