- Home /
Read .xml file content with WWW class
Hi all, I need to retrieve an .xml file inside the StreamingAssets folder using the WWW class and then read every single line inside it.
I'm able to retrieve the file and get it into a www type variable, but then I really can't read anything from it. I'd like to read it as it was a normal .xml file, but for some reasons I can't.
The error I get is: IsolatedStorageException: Could not find file "/UnityEngine.WWW".
This is the code of the retrieval:
string gesturesPath = System.IO.Path.Combine (Application.streamingAssetsPath, "Gestures/" + fileName + "/");
if (gesturesPath.Contains ("://")) {
Debug.Log("gesturesPath: " + gesturesPath);
for (int i = 0; i < 2; i++) {
WWW www = new WWW (gesturesPath + fileName + i + ".xml");
while (!www.isDone) {}
trainingSet.Add (GestureIO.ReadGestureFromFile (www.ToString()));
}
// some other code...
This is the code of the function to read from the .xml file:
public static Gesture ReadGestureFromFile(string fileName) {
XmlTextReader xmlReader = null;
Gesture gesture = null;
try {
xmlReader = new XmlTextReader(File.OpenText(fileName));
gesture = ReadGesture(xmlReader);
} finally {
if (xmlReader != null)
xmlReader.Close();
}
return gesture;
}
I assume that www.ToString() is not the right way to get the string path of the file the www variable is storing, and www.text is not what I need.
Oh yes, and the www variable returns "/UnityEngine.WWW", which I don't know what it is.
Any idea?
Thank you in advance and have a nice day!
www.text returns the actual content of the loaded files a string. You should write another method like ReadGestureFromXmlData(string xml) that uses that string directly ins$$anonymous$$d of interpreting the string as a filename.
Your answer
Follow this Question
Related Questions
Android Streaming asset path won't open 2 Answers
I can't figure out how to use www to copy a file / very confused about porting to android... 0 Answers
StreamingAssets Folder Max Size 2 Answers
loading Images from streaming assets in Android 0 Answers
How to read xml file on Android using www and StreamingAssets? 2 Answers