Load XML works on PC but not on Android
Hello everybody, I wrote an application which loads an XML Document. For different kind of shapes there are different x and y coordinates stored in the XML Document. After loading the XML Document I want to get access to these coordinates. When I run my application in the editor everything works fine. But if I compile it to android it doesn’t load the XML Document anymore. I don’t really know why this code didn’t work on android. I thought maybe on android the Resources folder cannot be found. So I stored my XML Document in an string to load the XML Document from string, this also works fine on PC but not in Android.
I load the XML Document and get access to the coordinates this way :
TextAsset textAsset = (TextAsset)Resources.Load("coordinates");
XmlDocument jobdoc = new XmlDocument();
jobdoc.LoadXml(textAsset.text);
//I tried to store the XML-Document in an string like this:
//string jobstring = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><TEST_JOB><JobLines><JobLine Name=\"\"><Pos_X_Y x=\"10\" y=\"10\" /><Orientation roll=\"-180\" yaw=\"180\" /><Conditions /></JobLine><JobLine Name=\"\"><Pos_X_Y x=\"20\" y=\"20\" /><Orientation roll=\"180\" yaw=\"0\" /><Conditions /></JobLine></JobLines></TEST_JOB>";
//XmlDocument jobdoc = new XmlDocument();
//jobdoc.LoadXml(jobstring);
XmlNodeList xNodesJob = jobdoc.SelectNodes("/TEST_JOB/JobLines/JobLine");
for (int i = 0; i < xNodesJob.Count; i++)
{
XmlNode xmlNodePos = xNodesJob[i].SelectSingleNode("Pos_X_Y");
if (xmlNodePos.Attributes.Count > 0)
{
x = ((double.Parse(xmlNodePos.Attributes["x"].Value)));
y = ((double.Parse(xmlNodePos.Attributes["y"].Value)));
}
}
Or maybe the mistake is not in the way I load the XML Document maybe I made a mistake by getting access to the coordinates. This is an example of the XML Document.
<TEST_JOB>
<JobLines>
<JobLine Name="">
<Pos_X_Y x="10" y="10" />
<Orientation roll="-180" yaw="180" />
<Conditions />
</JobLine>
<JobLine Name="">
<Pos_X_Y x="20" y="20" />
<Orientation roll="180" yaw="0" />
<Conditions />
</JobLine>
</JobLines>
</TEST_JOB>
I really hope somebody is able to help me I am struggling with that problem since one week. Greetings Kay