Sign in to follow this  

XML in Games?

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

In my game engine, I use XML for map files, settings, and some animation data. I do NOT use XML for scripts - I use a stripped-down form of C++. (XML is a great way of describing hierarchal DATA, but it's not a very good way to describe a procedure.)

I wrote my own XML loader within the framework of my engine.

Share this post


Link to post
Share on other sites
I've seen a few modern games that use XML but most game devs just come up with their own formats. I know for a fact that S.T.A.L.K.E.R. uses quite a lot of XML and even has a DLL dedicated to parsing it. That's more an exception than the rule though (not them writing their own parser but them using XML).

There's also a (fairly) good reason for not using XML in games. XML is expensive to parse and will increase load times. It's fine to use for small stuff like config files, but people tend to go nuts with it and put stuff like geometry data in it which is bad.

EDIT: Just so you don't get me wrong: I think XML is great, it's just sometimes better to go for a binary format. Also, using XML for scripting is fine... I just think the notation is overly verbose, but that's just me.

Share this post


Link to post
Share on other sites
Quote:
Original post by Harry Hunt
I've seen a few modern games that use XML but most game devs just come up with their own formats. I know for a fact that S.T.A.L.K.E.R. uses quite a lot of XML and even has a DLL dedicated to parsing it. That's more an exception than the rule though (not them writing their own parser but them using XML).

The Stalker team did NOT write their own parser! They simply built TinyXML as DLL.

Share this post


Link to post
Share on other sites
We use XML for commercial games, so does a nearby studio. XML is good for 'near human readable and editable', small size configuration files. When paired with a fast, light weight XML parser, can be usable for PC and Console games at load time. For bigger data structures, the data really needs to be converted into a more platform ready format for fast loading. XML has nothing to do with scripting unless you consider the concept of data driven configuration the same as script.

The summary of my rant is that XML is used. There is a time and place for it. It is often a better choice than yet another custom TEXT data file. The down side is embedding complex text data, particularly by hand, due to the XML syntax. Also the relatively slower speed compared to binary or memory mapped binary. Hand editing XML is of limited value due to limited commenting syntax etc. We also use a block data format that can be serialized as XML or binary. Nice to debug or hand edit for testing in XML.

By the way, we use MXML. Another reasonable choice is TinyXML. There are certainly lots more around. I believe Microsoft recently produced a small embedable parser for this kind of use.

Share this post


Link to post
Share on other sites
For the exact reasons mentioned by GregDude, XML makes an excellent intermediate format for games. It's great to be able to hack up XML files during game development and then at the end of development you could have a 'compiler' of sorts that converts XML files to your game's native binary format.

Not to mention using it as an intermediate format could aid in cross-platform development, and it makes debugging the initial implementation a little easier too, simply because you can visualize your data easier.

If you're planning on using XML you might want to weigh the difference between DOM and SAX parsers, as it will have an effect on the final efficiency of your XML load routines. I'm not sure which methods TinyXML or MXML use, but it would be worth checking out.

Hope this helps,
Matt Rudder

Share this post


Link to post
Share on other sites
We use XML for development files just like the above two post mention.

Its a good format for editing by both humans and programs, its standardized, and cross platform. Probably the main benefit is that you can easily and rapidly extend or modify a files structure, making it nice for development.

Basically our game editor reads and writes game assets in XML format, and then we build platform specific binary assets when deploying to dev kits.

We use TinyXML in case you're curious.




Share this post


Link to post
Share on other sites
It's kind of strange when XML is used, like in RenderMonkey.
It would take 1 minute to load when I was testig out the beta version and on my slow cpu. These days, with +2GHz cpus it is less of a problem but...

I use TinyXML for my config file so performance is not an issue.
I would never use it for game assets.
The same could be said for other text file formats like .obj and .ase
Too slow to load.

Share this post


Link to post
Share on other sites
I use XML all over. But only in content processing. By the time my code actually executes, I've converted everything(*) to a binary format.

I use TinyXML for C++, and the .NET XML / XPath stuff for C#.

(*) Actually not true, my GUI layouts are still in XML form, I just haven't fixed that yet.

Share this post


Link to post
Share on other sites

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