Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am working on a game, and the xml files are getting to be a few megs, and the final game might have a hundred megs of uncompressed xml. If I zip the xml files up I can get something that is about 3 megabytes to be under 100kb which shows that compressing the files will yield good results. How can I get the XML files compressed, and how would I uncompress them on the client's game?

I am planning to keep all my bullet patterns in one file, and planning to keep all the levels in one file. I am not to concerned about the files becoming undwieldy to edit, as I can add my own xml tags as categories to group data, and use a xml editor that can collapse tags. Is there a better way to do this?

share|improve this question
Are you dead-set on using XML? It tends to be a bit verbose. –  drxzcl Aug 10 '10 at 8:00
@Ranieri, what would you suggest? JSON? –  Richards Aug 25 '11 at 14:31
That's one option. Another is a custom binary format. Both have their advantages/disadvantages. Without knowing more about the application I can't really argue in favour of one over the other. –  drxzcl Aug 25 '11 at 21:37

3 Answers 3

up vote 2 down vote accepted

Wow. That's a lot of data. As Ricket said: Try to split the files into smaller chunks. Loading these huge files into memory will cause problems otherwise.

As for compression of the data: The easiest way would be to simply enable gzip compression on the server. When using Apache, you would have to enable mod_deflate and configure it, so that it also includes your xml files into compression. That way, all your files will be gzipped before sending to the client and automatically extracted by the client-browser.

If you can't modify the server settings (eg. enable gzip compression), then you could also zip your files manually and use ActionScript (AS3 Zip Library) to unzip the data. I used this on 3D data (Collada XML files) and it works a charm.

share|improve this answer
If I enable gzip compression, the flash client won't even know that the file has been zipped up? If so then I think that is all I would really need, correct? –  AttackingHobo Aug 11 '10 at 0:11
@AttackingHobo yes, correct. The beauty of this: you won't even notice the data is zipped, unless you look at the network traffic (and headers). –  bummzack Aug 11 '10 at 6:26

Switching to JSON rather than XML would also immediately save a lot of space. It's also a lot more readable, as a side effect.

Here's an AS3 library that includes JSON in/out: http://github.com/mikechambers/as3corelib

share|improve this answer
+ Flash Player 11 (in labs.adobe.com) has native JSON support! :) –  Richards Aug 25 '11 at 14:32

The question of how to compress and decompress data/files with ActionScript is a great candidate for asking at Stack Overflow; it's not game dev specific.

As for the question of is that a good idea, well you'll have to load, parse and keep the entire XML file in memory just to load one level. So I most certainly think you should split the levels into one xml file per level and then dynamically load and unload, so as not to waste valuable RAM.

I'm not sure what bullet patterns are. But you might run into the same issues with those.

However, I personally like XML, and I think it suits your usage very well. As you found, XML compression is extremely efficient (cancelling out the fact that it's human readable rather than binary) and I'm sure there are XML parsers in ActionScript for you to take advantage of.

share|improve this answer
Really good point about memory usage with large files. I will make sure to split those files up. And yeah I think the bullet patterns would have the problem mostly, as they are huge files compared to the levels. –  AttackingHobo Aug 10 '10 at 2:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.