TiXmlDocument *doc = newTiXmlDocument;
#if (CC_TARGET_PLATFORM ==CC_PLATFORM_ANDROID)
///android平台tinyxml读取文件方式(android平台需要从压缩文件中读取资源),xmlName为xml文件名称路径
unsigned char* pBuffer=NULL;
unsigned long bufferSize=0;
pBuffer=CCFileUtils::sharedFileUtils()->getFileData(xmlName, "r", &bufferSize);
if(pBuffer){
doc->Parse((const char*)pBuffer);
}else{
CCLog("android读取xml失败!");
CC_SAFE_DELETE(doc);
CC_SAFE_DELETE(pBuffer);
return;
}
#else
//ios平台tinyxml读取文件方式
if(doc->LoadFile(CCFileUtils::sharedFileUtils()->fullPathForFilename(xmlName).c_str()) == false)
{
CCLog("ios读取xml失败!%s");
CC_SAFE_DELETE(doc);
return;
}
#endif
注:tinyxml资源下载
http://download.csdn.net/detail/qwezcl/6598175