时间:2021-07-01 10:21:17 帮助过:31人阅读
时间: 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 Level Second 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