In order to write Tiled’s TMX file format I needed to do exactly this: figure out how to compress data, encode it as a string, and write it to XML.

I wrote down what I learned from using zlib, base64 and xswi - XML Stream writer for iOS (a single Objective-C class) while writing KoboldTouch‘s TMX writer.

I split it into two articles in the Essential Cocos2D section of the www.KoboldTouch.com homepage:

I was positively surprised how relatively painless zlib and base64 encoding worked (I expected the worst!) and how simple and effective xswi is for writing XML compared to any other XML library.

I’ll probably continue to add those articles to Essential Cocos2D rather than posting them on this blog. Confluence is just so much more convenient for writing technical documentation than WordPress.

Final word: Enjoy! :)


This article was brought to you by ...

I very much enjoy the learning process, the pushing of boundaries (mine and yours and that of technology), having the freedom to pursue whatever is on my mind, to boldly program what no one has programmed before, and to write about what I've learned. Help me help you by browsing the products in the Learn Cocos2D Store.

Tagged with:  

3 Responses to “How to compress, encode and write data to XML with zlib, base64 and xswi”

  1. Steffen, that 2nd link to the xswi page appears to be dead.

  2. base64 says:

    great share. thanks