Sign in to follow this  

I just don't have the grasp with TinyXML

This topic is 3112 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

If someone could show me how to access this data, it would be great. I've followed the tutorials but can't get anything to load from the files in C++:
<Game>
     <Window>
          <title="Some Program">
          <width="800">
          <height="600">
          <fullscreen="false">
     </Window>
</Game>


I gave up after trying to get something after 3 hours. I'm just so clueless now. Thanks. :]

Share this post


Link to post
Share on other sites
Hi, here some code you might find helpfull


TiXmlDocument xmldoc ("myxmlfile.xml");
xmldoc.LoadFile();
if (xmldoc.Error()) return false; // Errors be here

TiXmlAttribute *att = xmldoc.RootElement()->FirstAttribute();

while (att)
{
std::cout << att->Value() <<std::end;
att = att->Next();
}


TiXmlElement* child = xmldoc.RootElement()->FirstChildElement();

while (child)
{
std::cout << child->Value() <<std::endl; //the name of the tag
child = child->NextSiblingElement();
}


You can iterate every TiXmlElement to get it's sub elements and attributes. If you're not comfortable with the notion of recursion you might want to read about it. Try googling recursive programming in c++ or something of that sort.

Good Luck!

Share this post


Link to post
Share on other sites

This topic is 3112 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this