Unable to load XML file in ios using ofXml


#1

I like ofXml so I had hoped to use it in a ios project. It is not loading. That is not to say it should. I have use the same code in osx and it works.

I did #include “ofXml.h” in my ofApp.h

//--------------------------------------------------------------
void ofApp::setup(){

iPhGetDocsDir = ofxiOSGetDocumentsDirectory();

myFile = "";

xmlFile = iPhGetDocsDir + "level_0.xml";

date = ofToString(ofGetYear()) +"-"+ ofToString(ofGetMonth()) +"-"+ ofToString(ofGetDay()) +"-"+ ofToString(ofGetHours()) +"-"+ ofToString(ofGetMinutes())+"-"+ ofToString(ofGetSeconds());

message = "";

if( levelFile.load(xmlFile) ){
    message = xmlFile + " loaded!";
    cout << message << endl;
}else{
    message = "unable to load ";
    message += xmlFile;
    cout << message << endl;
}

if(levelFile.exists("SET")){
    getNum_SET = levelFile.getNumChildren("SET");
    cout << "getNum_SET " << getNum_SET << endl;
}else{
    cout << "   ********** SET did not exist ********** " << date << endl;
}

}

Here are my Errors

2017-05-16 12:28:59.617 loadXML[2026:116923] Creating OpenGL ES1 Renderer
[ error ] ofXml: couldn't load, "level_0.xml" not found
unable to load /Users/leemeredith/Library/Developer/CoreSimulator/Devices/********-****-****-****-************/data/Containers/Data/Application/F85990A8-17C2-47FF-8A3C-BEE689783AB9/Documents/level_0.xml
   ********** SET did not exist ********** 2017-5-16-12-28-59

I’ve looked on the forum and I am sorry if there are post that may have helped me answer this for myself. But was unable to find exactly what could have helped.

Thank you

I am using
of_v0.9.8_ios_release
Xcode 8.3.2


#2

where in the folder structure are you putting the .xml file?
I suspect you have it in the “data” folder, in which case the directory you are searching is wrong as you don’t want the “documents” directory
I would recommend getting your application to list the contents of the directory to check it’s looking at the correct place
HTH!