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

cocos2d-x-v3安卓平台tinyxml2读取xml出错,第1张

概述std::string filePath = FileUtils::getInstance()->fullPathForFilename(fileName); XMLDocument *pDoc = new XMLDocument(); XMLError errorId = pDoc->LoadFile(filePath.c_str()); log("errorId %d", errorId); 

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了(成功了)

总结

以上是内存溢出为你收集整理的cocos2d-x-v3安卓平台tinyxml2读取xml出错全部内容,希望文章能够帮你解决cocos2d-x-v3安卓平台tinyxml2读取xml出错所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1074551.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存