XML Loading works in PC... but not in Android

Hello everybody,

When I run my application in the Editor everything works fine. I load an XML this way:

xmlPreguntas.Load(Application.dataPath.ToString() + "/Resources/xxxxxxx.xml");

Then, I compile to Android, but hte XML document doesn’t load.

I was not sure why was this happening, but I read somewhere something that should work for me, loading by Resources.Load(). I tried that way typing this:

TextAsset textAsset = (TextAsset) Resources.Load("xxxxxx.xml");
XmlDocument xmlPreguntas = new XmlDocument();
xmlPreguntas.LoadXml(textAsset.text);

This code, instead, doens’t work nor in the Editor. The error shown is the next:
NullReferenceException: Object reference not set to an instance of an object, refering the last line. I thinks it’s telling me that the loading is failing, but I don’t really know why.

Hope there’s somebody smarter than me able to help me.

Greetings,

Alex.

do you try to load your xml with the second method but without the extension ?

Something like this :

TextAsset textAsset = (TextAsset)Resources.Load("FileNameWhitoutFileExtention", typeof(TextAsset));
XmlDocument xmldoc = new XmlDocument ();
xmldoc.LoadXml ( textAsset.text );

I can’t seem to work it out in 2019, in unity 2018.3. ANd i can’t understand why… Although I am trying to access my .xml file with GetElementById() method. My curr_file_name string variable is assigned runtime in the code (my game has 2 languages so I need to load different files) and it doesn’t have an extention.

TextAsset textAsset = (TextAsset)Resources.Load(curr_file_name, typeof(TextAsset));
XmlDocument doc = new XmlDocument();
doc.LoadXml(textAsset.text);
    
XmlElement greeting_word_id = doc.GetElementById("greeting_word");
greeting_word = greeting_word_id.InnerText;

Anyway. I compiled this code and I opened an APK file with zip. No xml files were there. What am I doing wrong? Please if anyone could work it out tell me HOW? I am struggling with this over a few weeks in a row… and I am getting really crazy. Thank you…