Possibility and Probability

A Python programmer with a personality thinking about space exploration

5 August 2006

The agony and the ecstasy of XML

by Nick

I have a real love/hate relationship with XML. On one hand I think it is really great format for the transmission of data especially if there are different systems involved. XML compresses well in most cases, and it is easy to “read” and pretty easy to parse. …and on the other hand XML can be a bitch and a half to work with. A debate I have with myself on a regular basis is: “Which is better, storing data in native structures or XML?”. Python is my weapon of choice these days and it has the wonderful functions pickle() and dict.update(). Both of these easy-to-use methods combined with the simple (easy to edit manually) format that Python writes out makes it so that you will want to write out python objects. However, complex data structures lead to complex looking files when they get written out. Plus if you want to load that data in another language (like lets say you write an editor to manage your data files), then you have to figure out what the written format is, and be careful that you don’t break the format. XML seems like an ideal solution, platform neutral, easy to look at (most of the time). Yet every time I try to process XML in a program (Python or Java) I feel like I have just slammed my head into a wall repeatedly. Right now I’m trying to create Python objects from XML, and just a little bit of effort in this direction has completely sapped my will to work on it. Don’t get me wrong, there’s some good resources out there on the net about this (in particular check out David Mertz’s page, he has written a ton on Python and they are all good as gold). Its just that getting hung up on XML problems depresses the hell out of me. (It probably has something to do with a job I was at a few years ago where I did a ton of XSLT. XSLT will drive you nuts in a hurry for some reason….) Anyways, I should quit my griping and just get back to work. It won’t fix itself…