- Home /
 
How do I read XML on iOS?
I have a xml in ProjectFolder/Assets/ but I can't load it on iOS. Output windows print that file can't be found. I have tried different scripts to get file path but neither work, for example:
 public static string GetiPhoneDocumentsPath () 
         { 
                 string path = Application.dataPath.Substring (0, Application.dataPath.Length - 5); 
                 path = path.Substring(0, path.LastIndexOf('/'));  
                 return path + "/Documents"; 
         }
 //-----------------------------------------------------------------------------
 string fileNameBase = Application.dataPath.Substring(0, Application.dataPath.LastIndexOf('/'));
 fileName = fileNameBase.Substring(0, fileNameBase.LastIndexOf('/')) + "/Documents/" + FILE_NAME;
 //-----------------------------------------------------------------------------
 string fileName = Application.persistentDataPath + "/" + FILE_NAME;
 //-----------------------------------------------------------------------------
 Path.Combine( Application.persistentDataPath, FILE_NAME);
 
               So... what am I doing wrong? Do I have to change some settings in Unity Editor? Where do I have to put the xml file? How do I load a xml file on iPhone/iPad?
Answer by jasonbelmonti · Nov 10, 2011 at 07:53 PM
I think whatever you're trying to load might have to be in the a folder named "Resources" in the Project folder and accessed with a call to Resources.Load()
maybe?
Answer by yusufulutas · Nov 11, 2011 at 10:55 AM
I would recommend this address review. http://unity3d.com/support/documentation/ScriptReference/Application-dataPath.html
Your answer
 
             Follow this Question
Related Questions
Unity modules for iOS? 1 Answer
Setting resolutions for iPad and iPhone 0 Answers
How to identify each iOS device? 1 Answer
Xcode build crashes 0 Answers