Which XML library to use?

Martin von Loewis loewis at informatik.hu-berlin.de
Wed Aug 8 07:20:27 EDT 2001


pibble at yahoo.com (Preston Landers) writes:

> We could probably continue to use the PyXML 0.5.x release, except
> we've found it won't work very well in Windows with Python 2.1.  (It
> seems to work fine on Unix...)

I'm surprised that it does, because there is an xml package in Python
2.1, so your PyXML 0.5 installation should not be visible.

> 1) Update our code to use the XML libraries now built-in to Python 2.1
> (a non-trivial task.)

That is what I would recommend to do.

> 2) Update our code to use the PyXML 0.6.x release.  I see that there
> is a Win32 release of this library compatible with Python 2.1. 
> However, it looks like the interface is different enough from the 0.5
> release to be just as much work as option #1.

That is probably the case indeed.

> 3) Somehow hack PyXML 0.5 to work with Python2.1 on Win32.  We would
> not have to change any of our legacy code.

At a minimum, you have to hack Python to remove the xml package, or
hack PyXML 0.5 to rename the xml package, in which case you'd have to
change your legacy code. There might be other things where 0.5 fails
to cooperate with 2.1 as well, e.g. that you get two copies of
pyexpat.

> Basically, I'm trying to decide between the first two options and need
> some help.
> Which is "recommended" set of XML libraries? The ones now included
> with Python 2.1.1 or the PyXML 0.6.6 release?

You did not explain much what features exactly your application
uses. If the SAX interfaces on top of pyexpat, or minidom, is enough
for your needs, I recommend to go with the code in the Python
libraries. If you need a full DOM, or xmlproc, I recommend to use
PyXML 0.6.6.

> It looks like the PyXML interface has changed significantly from 0.5.x
> versions, so it wouldn't be a drop-in replacement for us.  Since it
> looks like I'll be making extensive changes to our code for a new API
> no matter what, the question becomes "which set of XML libraries is
> more stable / 'better'?"

The APIs of the various DOM implementations all follow the Python
library documentation, as far as that is applicable, so it is not a
too large effort to port from, say, minidom to 4DOM.

Regards,
Martin



More information about the Python-list mailing list