views:

870

answers:

5

On a project I'm working on we're using LibXML2 (import lxml) because it has Objectify. But we're finding that getting it to work in OSX is an incredibly involved process.

Does anyone have suggestions for clean cross platform xml libraries that don't have excessive dependencies on C libraries?

+8  A: 

I´ve used ElementTree http://effbot.org/zone/element-index.htm

Tiago
ElementTree was even included into the base Python distro in version 2.5. Most Macs are running older versions of Python, but you can either upgrade Python or install ElementTree as a site package.
Ben Blank
We're investigating ElementTree right now, although we're finding it very slow compared to Objectify. Something like 20 seconds to parse a 14MB XML file.
Soviut
you are using cElementTree, right? ( http://docs.python.org/library/xml.etree.elementtree.html )
llimllib
One major issue we've noticed with ElementTree is that its very slow compared to lxml.
Soviut
A: 

xml.dom, which comes with Python

We're looking for tools that simplify xml parsing, xml.dom is far too raw for our purposes. We need elements turned into objects for us without having to code our own ORM.
Soviut
+1  A: 

What little XML I do with Python is rather simple so please take this answer with a grain of salt.

Here is an XML/Python FAQ that could be of interest: http://www.rexx.com/~dkuhlman/pyxmlfaq.html#are-there-other-dom-implementations-for-python

ElementTree seems to be used a lot and then depending on your application and the complexity of the XML you're doing, could you use minidom? http://docs.python.org/library/xml.dom.minidom.html?highlight=xml#module-xml.dom.minidom

As far as being cross platform, minidom is part of the Python library, if that's not a guarantee of it working on your platform, I don't know what is.

Not knowing what you're doing, BeautifulSoup might be an option as well: http://www.crummy.com/software/BeautifulSoup/

pboucher
A: 

Don't know about excessive - expat and things that rely on it (eg. minidom, etree) are in the stdlib so shouldn't be too hard to get hold of.

pxdom is pure Python, contains a parser and is rigorously standards compliant, but is not at all fast.

bobince
A: 

I use PyRXP, which must be compiled, but does so on all of the platforms I have tried.

Matthew Schinckel
Do you know if, once compiled, it will be "ingested" properly into a bundled application using py2exe or py2app?
Soviut
Not sure. I've never used these tools.
Matthew Schinckel