我需要解析有父子关系嵌套的 xml结构 。
使用 cocos2d::CCSAXDelegator 能否像 java dom4j 一样通过父节点去获取子节点。
xx.xml
// the XML parser calls here with all the elements
void GCScene::startElement(void *ctx, const char *name, const char **atts){
CC_UNUSED_PARAM(ctx);
std::string elementName = (char*)name;
std::map *attributeDict = new std::map();
if(atts && atts[0])
{
for(int i = 0; atts[i]; i += 2)
{
std::string key = (char*)atts[i];
std::string value = (char*)atts[i+1];
attributeDict->insert(pair(key, value));
CCLOG("key %s value--> %s ",key.c_str(),value.c_str());
}
}
if (elementName=="res") {
CCLOG("res");
}else if(elementName=="group") {
CCLOG("group ");
}else if(elementName=="packer") {
CCLOG("packer ");
}
}
3Q