cocos2d-x3.0 XML解析
来源:未知 责任编辑:责任编辑 发表时间:2014-05-20 18:26 点击:次
在2dx3.0中xml解析已经不用自己找库了,已经为我们集成好了。
text.xml
2012050808 crystal T74 T74 2012050809 goodmao T77
添加头文件:.h
#include "cocos-ext.h" #include "tinyxml2/tinyxml2.h" using namespace tinyxml2;
.cpp
//获取文件路径
const char* file_path = FileUtils::getInstance()->fullPathForFilename("text.xml").c_str();
log("external file path = %s",file_path);
XMLDocument* myDocment = new tinyxml2::XMLDocument();
//加载文件
myDocment->LoadFile(file_path);
tinyxml2::XMLElement* rootElement = myDocment->RootElement();
XMLElement* studentElement = rootElement->FirstChildElement();
while (studentElement) {
XMLElement* element = studentElement->FirstChildElement();
while (element) {
log("信息 : %s",element->GetText());
element = element->NextSiblingElement();
}
studentElement = studentElement->NextSiblingElement();
}
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 进入详细评论页>>

![cocos2d_x+lua[2]](/uploads/allimg/131030/110J64609-0-lp.jpg)








