What XML lib to use?

Paul Boddie paul at boddie.org.uk
Wed Sep 14 17:44:26 EDT 2005


Fredrik Lundh wrote:
> Paul Boddie wrote:

[On interoperability]

> > For example, PyQt and PyKDE expose various DOMs of the purest
> > "non-Pythonic" kind; Mozilla exposes DOMs for XML and HTML
>
> I didn't see anything about manipulating an application's internal
> data structures in the original post, but I might have missed some-
> thing.

Well, manipulating documents in Mozilla and KHTML are just examples, as
I pointed out, and whilst I'd agree that the in-process restrictions
Mozilla appears to place on full participants in its component system
does kind of mean that the Mozilla DOM is an "application's internal
data structure", the opportunities are more open for KHTML in that one
isn't limited to just automating some application. Moreover, the XML
APIs exposed by PyQt are also available for general XML processing,
whether you regard them as performant or not.

> For stand-alone XML manipulation in Python, my point still stands:
> programs using DOM and SAX are more bloated and slower than
> the alternatives.

Your point was that "there are no *sane* reasons to use SAX or DOM in
Python", which actually isn't true. Sure, processing a 100GB XML
document using the DOM isn't a sensible strategy (with this generation
of hardware!), and SAX isn't necessarily the most elegant way of
expressing the processing logic, and other tools and APIs exist to
perform such tasks more efficiently and elegantly, but then "to
read/write XML files" leaves the questioner's field of endeavour pretty
much open to interpretation. Somewhere amongst the many fields of
endeavour there are places where the DOM (whilst not as "Pythonic" as
some might like) certainly is a valid choice, possibly because it's the
only choice - all thanks to interoperability, as I said. ;-)

Paul




More information about the Python-list mailing list