Jay Taylor | programmer notes



For Python, lxml superior to dom/minidom

I first looked at Python’s dom and minidom modules last Friday.  There was an initial wave of shock for me after looking over the apparently complex API.  Eventually I remembered that all I wanted to do was create a straightforward RSS feed document from a MySQL database.   I had to go to class so I didn’t make much progress on that attempt.

Today I revisited the project and randomly happened upon a 3rd party Python XML library called ‘lxml‘.  This module is purported to be an order of magnitude faster than Python’s dom/minidom (rendering them quite slow, painfully slow, even, by comparison).  Not that execution speed is a particularly important to me in this instance.  Anyways, after 4 minutes to compile the module from their Subversion repository (my server is slow, I guess..), 2 minutes of the tutorial, and approximately 10 minutes coding, I had the script doing what I had originally set out to do.  The lxml API seems much more practical, at least in this case where the task and goal were pretty simple (naturally, I can’t account for other scenarios).  At any rate, I guess this time around its “Vive lxml”.

At this point, the Python dom and minidom modules do have a feeling of circumstantial familiarity.  They remind me of the my days of having to troubleshoot and develop fixes to address protocol incompatibilities between the Java SOAP API implementation with PHP Pear SOAP’s API.  Shudder.

This is the source that pointed me to lxml.

Related posts:

  1. Python Error/Exception: IOError: [Errno 32] Broken pipe
  2. Windows 7 Twilight Zone Encounter: TCP/Network connection unbroken by hibernation cycle

RSS Feed

No comments yet.

Leave a comment!

You must be logged in to post a comment.



Find it!