For my Android game, I’m trying to read (and eventually write) to xml file. To do that, I’m using a StreamingAssets folder that I created in the Assets folder.
The main source of information are those from Unity doc:
http://docs.unity3d.com/Documentation/Manual/StreamingAssets.html
http://docs.unity3d.com/Documentation/ScriptReference/WWW.html
I tried many different paths and setting (External SDCard and Internal Only). I searched a lot for solution, but without success.
On my Android Nexus 7 tablet in my try catch I get: System.Xml.XmlException: Document element did not appear. Line 1, position1.
Line 1 of my xml file is the basic xml version=“1.0” encoding=“ISO-8859-15”.
If I change the file name to something inexistent, I get the same exception.
This is my current cleaned code:
//OurText inherits from MonoBehaviour.
//Text is inherited.
public class TextMainMenuLineTwo : OurText
{
protected override void Start ()
{
base.Start();
StartCoroutine( Init() );
}
public IEnumerator Init()
{
string file;
string fileName;
WWW www;
XmlDocument xmlDocument;
file = "Texts.xml";
fileName = "jar:file//" + Application.dataPath + "!/assets/" + file;
www = new WWW(fileName);
yield return www;
xmlDocument = new XmlDocument();
try
{
xmlDocument.LoadXml(www.text);
Text = xmlDocument.SelectSingleNode ("texts/mainMenuTitle").InnerText;
}
catch(Exception e)
{
Text = e.ToString();
}
}
}
Thank you all.