时间: 2012.4.10 平台: vs2010, cocos2d-x *.12.* , tinyxml:2.6.2 其中:tinyxml 下载:http://sourceforge.net/projects/tinyxml/files/ tinyxml相关网页: www.sourceforge.net/projects/tinyxml original code by lee thomason (www.grinninglizard.com) 本
时间: 2012.4.10
平台: vs2010, cocos2d-x *.12.* , tinyxml:2.6.2
其中:tinyxml 下载:http://sourceforge.net/projects/tinyxml/files/
tinyxml相关网页:
www.sourceforge.net/projects/tinyxml
original code by lee thomason (www.grinninglizard.com)
本文假定你已经配置好cocos2d-x;
新建工程
将一下文件导入到classes目录
建立一个 test.xml
first levelsecond level
将这个xml文件放到resource目录下;
然后开始读取吧:(首先包括头文件 #include tinyxml.h)
tixmldocument* xmldoc = new tixmldocument(ccfileutils::fullpathfromrelativepath(test.xml)); xmldoc->loadfile(); tixmlelement* rootelement = xmldoc->rootelement(); cclog(%s, rootelement->value()); tixmlelement* firstelement = rootelement->firstchildelement(); tixmlelement* secondelement = firstelement->nextsiblingelement(); cclog(firstelement:%s secondelement:%s, firstelement->gettext(), secondelement->gettext()); delete xmldoc;
ok,很easy吧。
http://blog.csdn.net/hoyt00/article/details/6769883