cocos2d-x-v3安卓平台tinyxml2读取xml出错

来源:互联网 发布:sql server denty_rank 编辑:程序博客网 时间:2024/06/04 20:18

std::string filePath = FileUtils::getInstance()->fullPathForFilename(fileName);

XMLDocument *pDoc = new XMLDocument();
XMLError errorId = pDoc->LoadFile(filePath.c_str());
log("errorId %d", errorId); 

fileName在Android下assets目录,以上代码errorId总为3 (找不到)


原因是FileUtils返回全路径并没做好android的适配。


可以这么绕开:

std::string content = FileUtils::getInstance()->getStringFromFile(fileName);
XMLError errorId = pDoc->Parse(content.c_str());

这么返回就为0了(成功了)



0 0
原创粉丝点击