[lxml-dev] ET compatible parser interfaces

Stefan Behnel stefan_ml at behnel.de
Tue Sep 11 22:00:04 CEST 2007


Hi all,

just wanted to send a note that I implemented ElementTree compatible
interfaces on top of lxml's parsers. This means that you can now do two
additional things: use "parser.feed(data)" and "parser.close()" to pass data
to a parser in a step-by-step fashion, and pass a "target" keyword argument to
a parser to receive SAX-like method calls on the object you pass. The
interface is described here:

http://effbot.org/elementtree/elementtree-xmlparser.htm

This *should* work for both XML and HTML (the latter was hard enough to
implement due to differences in the libxml2 API).

I also added a parser section to the lxml tutorial while I was at it.

The current down-side is that the trunk will require a patched version of
Cython until the next Cython release. I added the patch to SVN (and to the
Cython bug tracker). The reason is a syntax addition that allows grabbing the
GIL during a function call, which simplifies the implementation considerably.

Have fun,
Stefan


More information about the lxml-dev mailing list