xml文件的解析

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;
}
上一篇:初探接口测试框架--python系列7


下一篇:WCF service 获取 client 端的 IP 和 port (转)