Jump to content
  • Advertisement
Sign in to follow this  
nickwinters

Parsing XML with C++

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

Most of my coding has been with C#, and I like XML as a data storage format. I'm about to develop my next game in C++, and would like to use XML. A google on it pulls up a bunch of different libraries and tutorials. What libraries would you advise? I'd like something that's easy to use with VC++ 7.0. Thanks. -Nick

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I used tinyxml briefly. Had it working in just a few hours to read some files I invented.

I did not try any others, or even use that one much though. But if you don't get any better advice that is at least one that isn't awful. :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
xerces is what they are using here at work to parse game files, a much bigger library than tinyxml (my priority was learning the lib in less than 1 day when I chose tinyxml).

Share this post


Link to post
Share on other sites
We use TinyXML for our game and I like it. You're up and running in a hour or two. But it can't do validation. It's as small as possible, it's can parse a XML file and write a XML file.

If you need more stuff, a full packade XML parser library, I'd go with Xerces.

Share this post


Link to post
Share on other sites
Another vote for TinyXML. I can't see many reasons why you'd need to do validation in a computer game, so TinyXML should be fine.

Share this post


Link to post
Share on other sites

ive used tinyxml for 2 of my projects and its worked a dream.


tinyxml does validation, by returning null pointers on an error.

Share this post


Link to post
Share on other sites
I also have used TinyXML. I did have problems with it when dealing with large data files (only 20MB or so) since it used up about 1500% (15 times) the file size in memory footprint, after parsing the file into a full DOM tree. I modified the library to use a pull-parse method instead, and it now uses only the memory required to load the file into memory. I could feasibly remove that requirement also and go with a stream-based system that would lower memory footprint yet further. In any case, this modification was necessary to avoid hitting the 2GB address limit with larger files. Now I need to find a reliable way to write the XML out without needing to build a full DOM tree first...

Share this post


Link to post
Share on other sites
you need to do validation FOR SURE, in any game that wants to let the users modify the files ... for modding ...

Share this post


Link to post
Share on other sites
When I said it didn't do validation, I meant with a DTD or Schema.

Xai has a point. But unless you're aming for a game dev kit, then you don't have to care. Besides:
A) You can do a type of validation yourself, that's what I do. Write a wrapper, so when you're loading something then it type checks the data against the data in the file. Say you want to load a float and you get a char, that's when you kick of a error message and stop loading. Works very well :)
B) If you aim at modding, supply a tool that does the saving. No one should really have to be editing XML files when making a mode, that's pure evil :P

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!