Jump to content
  • Advertisement
Sign in to follow this  

TinyXml Data

This topic is 3759 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have TinyXml to open a xml file for me. how would I extract the data from the xml file to use it in the program? Like having my xml file setup like so.

How would I grab the be able to actually use that information?

Share this post

Link to post
Share on other sites
I'm using TiCPP to load my map data from XML.

For the given XML:
<tilemap width="8" height="2" size="16">
<![CDATA[0 1 0 2 3 4 5 66 0 2 196 0 0 2006 0 7]]>

I do the following:
int width, height, tileSize;

/*Get width, height, and tileSize*/
ticpp::Element* root = doc.FirstChildElement();

root->GetAttribute<int>("width", &width, true);
root->GetAttribute<int>("height", &height, true);
root->GetAttribute<int>("size", &tileSize, true);

/*Get grid data -- it's a string that needs to be tokenized...*/
ticpp::Element* data = root->FirstChildElement();

std::string gridData;
data->GetText<std::string>(&gridData, true);

/*Tokenize the grid data... etc...*/

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!