Painless XML parsing using Python

I recently had to parse some XML data and as usual I used python for this task. There are several XML parsers available but XML is a pain and parsing them also is. I first used the minidom interface and it was working quite well until I had to parse a 40Mb file...which basically intended to use more than 2Gb of Ram during parsing. This is not acceptable. So I digged a bit around and saw that using the Sax python interface should be more stable. But using Sax is also a pain. So I found a small code snippet that works fairly well and that parses your xml document and puts the info into python internal datastructures (objects and lists). Then it's quite neat to browse and access information.

Have a look at this example : http://code.activestate.com/recipes/534109-xml-to-python-data-structure/