1. xml文件的解析
void CDataMgr::readStringData()
{
std::string xml_name = "config/string.xml";
TiXmlDocument * xmlDoc = new TiXmlDocument( xml_name.c_str() );
unsigned long nLength = ;
char * pBuffer = ( char * )cocos2d::CCFileUtils::sharedFileUtils()->getFileData( xml_name.c_str(),"rb", &nLength );
xmlDoc->loadMemory( pBuffer, nLength ); int index = ;
TiXmlElement * RootElement = xmlDoc->RootElement();
for ( TiXmlElement * rootelement = RootElement->FirstChildElement(); rootelement != ; rootelement = rootelement->NextSiblingElement() )
{
if ( index == ) { index ++; continue; } int id = ;
rootelement->QueryIntAttribute( "id", &id );
std::string value = rootelement->Attribute( "value" );
mMapString[ id ] = value;
}
CC_SAFE_DELETE( pBuffer );
delete xmlDoc;
}