Cocos2d-x3.0 XML Parsing

Source: Internet
Author: User
Tags xsl

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 ();}





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.