I'm working on a Cocos2dx C++ project and I am trying to load a XMLfile and parse it with rapidxml.
The Win32 build works great with this code.
rapidxml::file<> xmlFile("myxml.xml");
xml_document<> doc; // character type defaults to char
doc.parse<0>(xmlFile.data()); // 0 means default parse flags
xml_node<> *main = doc.first_node(); //Get the main node that contains everything
This does not work for the Android build. It's most likely because "myxml.xml" can't be found. So my solution was to load the file in a different way.
So I tried to replace the xmlFile.data() with this. The mobile could now locate and read the data but I was unable to parse it trough rapidxml.
const unsigned char* xmldata = CCFileUtils::sharedFileUtils()->getFileData("myxml.xml", "r", &tmpSize);
But then I have no idea how to parse it.
This is another way of getting the data but still no idea how to parse with rapidxml.
std::string xmldata2 = CCFileUtils::sharedFileUtils()->getStringFromFile("myxml.xml");
Any ideas how to parse this in rapidxml, or any other suggestions how to solve this?
I'm new to c++ so any help is very much appreciated.