Sign in to follow this  

XML Resource Files

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

Howdy all, Merry Christmas! I had a question regarding using XML files for my resources in my game. Let's take a simplistic case where I have an XML file that holds a list of all the text strings in the game. I decided on using TinyXML just because that's one that seems to be popular around here. The first thing you do with Tiny is call "LoadFile", and them from then on, you can call tiny's various functions to get elements and values and whatnot. My question is, at the application initialization, would I recursively grab all elements and their values and store this data in some sort of data structure OR would I do this: whenever a resource is needed, recursively find that element and its value with Tiny's parsing capabilities? Does this make sense? I guess I'm confused if I do the first method, how to store all that data or to go with the second method? Thanks!

Share this post


Link to post
Share on other sites
I really depends on your application. If you can create a data structure that's easier or clearer to use than accessing TinyXML's DOM directly, then do that. Especially if you can store the data in a SC++L container.

If the data structure would just turn into a generic tree anyway, you might be better off just using TinyXML's API. Just make sure that you only load the document once, not everytime you access the file [smile].

Share this post


Link to post
Share on other sites
In your example - which is basically an array of strings mapped to a name/index - it's probably easier to extract it all at load-time into a std::map object.

However it would be even better perhaps to use a StringTable resource in your .rc file - but I guess you just used this as an example?

Share this post


Link to post
Share on other sites

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