In 2dx3. 0, you no longer need to find the database for xml parsing. It has been integrated for us.
Text. xml
2012050808
Crystal
T74
T74
2012050809
Goodmao
T77
Add header file:. h
#include "cocos-ext.h"#include "tinyxml2/tinyxml2.h"using namespace tinyxml2;
. Cpp
// Obtain the file path const char * file_path = FileUtils: getInstance ()-> fullPathForFilename ("text. xml "). c_str (); log ("external file path = % s", file_path); XMLDocument * myDocment = new tinyxml2: XMLDocument (); // load the file myDocment-> LoadFile (file_path); tinyxml2: XMLElement * rootElement = myDocment-> RootElement (); XMLElement * studentElement = rootElement-> FirstChildElement (); while (studentElement) {XMLElement * element = studentElement-> FirstChildElement (); while (element) {log ("info: % s", element-> GetText ()); element = element-> NextSiblingElement ();} studentElement = studentElement-> NextSiblingElement ();}