- Home /
Android and XML (Reading/Wirting)
Hello everyone,
I have been trying to work with an XML file to store my data.
I was able to read and write data into my xml file when I test the program on my PC. But when I build the program for the android, only the reading works.
Here is how I do it. I attach my xml file to the variable TA in the Inspector
public static XmlDocument XmlDoc;
public static XmlNodeList xnl;
public TextAsset TA;
void Start()
{
XmlDoc = new XmlDocument();
XmlDoc.Load(new StringReader(TA.text));
xnl = XmlDoc.GetElementsByTagName("level");
DataFilePath = Application.dataPath + "/Data/Data.txt";
// Play with the data / update some innertext ....
XmlDoc.Save(DataFilePath);
}
This works on my PC ... but not on my android ...
Is there is a better way?
Answer by cowlinator · Feb 13, 2013 at 12:49 AM
put the XML file in a folder called "Resources". then use Resources.Load(path), where the root of path is the resources folder.
Your answer
Follow this Question
Related Questions
Unity/Google Play Games set up Android. Error 0 Answers
How to read xml file on Android using www and StreamingAssets? 2 Answers
How to refresh assets during run time of a build ? 0 Answers
ArgumentException: Path is empty while saving data in an XML 0 Answers
Performance question - Loading large-ish amounts of text data in a mobile game? 1 Answer