Givin libxml2 some love

I started working with libxml2 a few months ago and I've really grown to love it. After spending several years working with Java APIs like SAX and DOM, I'm absolutely thrilled with the simplicity of the libxml Python API. Yeah it's not standard, but who cares. I could never remember how to write SAX or DOM code anyway. No matter how much I used it I always had to open a book, with libxml it's just so much more natural. The libxml API still has all kinds of problems, but it's by far the most productive XML API I've ever used.

My favorite feature by far, absolutely no question, the brain dead simple XPath API.

import libxml2
doc = libxml2.parseFile("something.xml")
results = doc.xpathEval("/some/path")

for result in results:
	# do something cool here

A few lines of code, whole worlds of power. To me XPath is the swiss army knife of XML tools. Of course you'd never guess that if you were to look at the source code for Syncato.

Posted by Kimbro Staken

Wednesday Oct 15, 2003 at 8:04 PM
Recommended Sites