TBXML – XML parsing on the iPhone
Just wanted to remind people about TBXML developed by Tom Bradley. This is an Objective-C based XML parser for the iPhone that is QUICK and light on resources. It has a really simple API and can be implemented really quickly.
If all you want to do is read and parse XML then this is a library you should check out. It is open source so you can see how its been done and change as necessary. If you don’t want to change it yourself then drop Tom a note and he is very quick in making changes that fit with the purpose of the library.
I use TBXML for processing all my XML in SLQ including the tile map and particle config files. You will find a link to the site in the links panel on the right in the Game Development link section.
Mike
12 Comments
Simon on January 7th, 2010
Hi Mike,
A newb question for you. What is SLQ?
I saw a reference to it in your latest tutorial but it’s not something I’ve come across could you enlighten me?
Thanks
Simon
mike on January 8th, 2010
Hi Simon
SLQ = Sir Lamorak’s Quest
This is the game I am developing with the book I’m writing. The book is basically documenting how I wrote the game engine and game content for SLQ to provide people with a complete project for them to review and use as necessary etc.
There will be a new film of SLQ up shortly for people to see how it looks after the beta testing it has just been through.
Mike
mike on January 8th, 2010
Hi Scott, sorry, missed your post until now.
When I was using the KissXML and unpacked layer data in my tile map it was taking around 20 seconds to process all the map information. Since moving to TBXML and using gzipped data, the load and process time is down to 600ms.
Now not all of that was down to TBXML. Using gzipped layer data for example is a big speed increase and that could be done with KissXML if you implemented your own unzip functions.
I also made other optimizations in the code that was taking the XML data and processing it i.e. creating object instances and doors in my map. Those also made a real difference.
Whilst this could be done with NSXMLParser, KissXML etc, the thing I love about TBXML is that it is such a simple API and there is no fat with it. As this is all I need TBXML fits my needs perfectly.
Mike
Simon on January 8th, 2010
Lol SLQ Seems so obvious now. Thanks
Simon on January 21st, 2010
Hi Mike,
Would you be willing to share (run through) the updated parseMapFile method. As I’m struggling to implement TBXML. Any assistance would be greatly appreciated. Thanks
Simon
mike on January 22nd, 2010
Hi Simon. I’m in San Francisco at the moment on business, but I’ll get something to you over the weekend to see if it helps :o)
Mike
Simon on January 22nd, 2010
Mike,
That will be great. Thanks
Simon
russell on February 6th, 2010
Would really like a How-To on this, as the examples they give just suck.
I need something that will work with wordpress xml.
russell on February 6th, 2010
What I want to do, is allow a user to see the latest titles from the xml and click on them and it slides to the story.
I thought was simple but as I am finding VERY hard
Anonymous on February 20th, 2010
Hi Mike
I am new to objective c and xcode so this might be a stupid question.
I find the TBXML examples self explanatory but cannot get it running. It seems that whatever i try to do i get a “EXC_BAD_ACCESS”. I also tried the bug fix posted on the tbxml website but it didn’t help.




Scott on January 7th, 2010
Hey Mike,
I have been wanting to replace the KissXML library with this one ever since you mentioned it in one of your tutorials, but have not gotten around to it yet. I’ve also found that the Kiss library has met my needs so far, but I’ve only used it on svery small maps.
My next game is much more involved with a much larger tile map. I know you ran some benchmark tests at one point between the two libraries. Can you remind me what you found ?
Thanks,
-Scott