- Home /
Filestream for XMLReader not working on iOS
So I have a local XML file that I need to read and it works fine in the editor. However, it does not work on iOS.
I have the XML document in the StreamingAssets folder.
I create a file stream via:
stream = new FileStream (System.IO.Path.Combine(Application.streamingAssetsPath, "DrawerData.xml"), FileMode.Open);
Then I pass the stream to a method to parse the XML which starts like that:
void ReadXML (Stream stream)
{
XmlReaderSettings settings = new XmlReaderSettings ();
using (XmlReader reader = XmlReader.Create(stream, settings)) {
//Parsing here ....
}
}
This works great in the editor however when I try to run on iPad xcode spits this out:
UnauthorizedAccessException: Access to the path "/var/mobile/Applications/355AAD36-FA10-442B-9BE3-0CC5BE938717/Appname.app/Data/Raw/DrawerData.xml" is denied.
Thanks for the reply.
I ended up getting it to work by saving the X$$anonymous$$L as a .txt file.
Then read it in as a TextAsset.
Then ins$$anonymous$$d of using a filestream I used a $$anonymous$$emoryStream on the textAsset.bytes.
The remainder of the code worked as is!
Answer by justin_iSO · Sep 20, 2013 at 02:18 PM
See comments above and use this:
http://answers.unity3d.com/questions/132753/how-do-i-read-xml-on-iphone.html