views:

107

answers:

1

Currently I have 2 varieties, LXML and libXML2 that both seem to work. I have tried benchmarking both, specifically for parsing memory string and files into XML and importing XSLT stylesheets and applying them. While pure performance based tests indicate that LXML comes on top (applying stylesheets specifically) libxml2 seems to have been used as defacto-standard for many other languages. In addition, during parsing LXML seems to have some difficulties with entity substitutions.

My question primarily is: have anyone used, successfully LXML in production, and what were your impressions?

+2  A: 

I've used LXML and been very impressed. The flexibility offered by having both the etree-like and objectify interfaces is pretty handy. I also like the fact that I don't have to have any separate text nodes.

As far as entity substitutions, I had a few issues too, but for me it was a matter of giving the parser the right options when creating it.

For example, if you're trying to load entities from a remote DTD, you might try something like:

parser = etree.XMLParser(load_dtd=True, no_network=False)

The no_network flag defaults to True and is a bit counter-intuitive in my opinion, but that's really the only snag I've hit with it.

Kevin Horn
That settles it then! Thank you!
Terry Felkrow