直接用tinyxml2的loadFile,加载一个XML文件,在WIN PC下是可以的,但在真机下失败。
const char* filepath = "test.xml";
tinyxml2::XMLDocument* xmlfile = new tinyxml2::XMLDocument();
auto ret = xmlfile->loadFile(filepath); //这里失败
修正:
const char* filepath = "test.xml";
tinyxml2::XMLDocument* xmlfile = new tinyxml2::XMLDocument();
auto content = CCFileUtils::getInstance()->getDataFromFile(filepath);
auto ret = xmlfile->Parse((const char*)content.getBytes(), content.getSize());