471,326 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,326 software developers and data experts.

Which XML?

I've found a lot of XML libraries for Python. Any advices on which
one to use (or *not* to use)? My requirements are: support for XPath,
stability (a must, segfaults are not an option), with DOM API and good
performance desirable.

Thanks for any advice.

--
Bruno Barberi Gnecco <brunobg_at_users.sourceforge.net>
Jun 24 '07 #1
5 1060
On Jun 24, 7:04 pm, Bruno Barberi Gnecco
<brunobgDELETET...@users.sourceforge.netwrote:
I've found a lot of XML libraries for Python. Any advices on which
one to use (or *not* to use)? My requirements are: support for XPath,
stability (a must, segfaults are not an option), with DOM API and good
performance desirable.

Thanks for any advice.

--
Bruno Barberi Gnecco <brunobg_at_users.sourceforge.net>
I use the minidom module for most of my XML work, but I don't think it
has much in the way of XPath. I think lxml might work better for that
sort of thing and I think it's part of ElementTree:

http://codespeak.net/lxml/dev/objectify.html

This guy kind of reviews the major XML modules:

http://www.oreillynet.com/onlamp/blo..._xml_pyth.html

Mike

Jun 25 '07 #2
ky******@gmail.com wrote:
On Jun 24, 7:04 pm, Bruno Barberi Gnecco
<brunobgDELETET...@users.sourceforge.netwrote:
> I've found a lot of XML libraries for Python. Any advices on which
one to use (or *not* to use)? My requirements are: support for XPath,
stability (a must, segfaults are not an option), with DOM API and good
performance desirable.

I use the minidom module for most of my XML work, but I don't think it
has much in the way of XPath. I think lxml might work better for that
sort of thing and I think it's part of ElementTree:

http://codespeak.net/lxml/dev/objectify.html
lxml is not part of ElementTree (only mostly compatible), but it's a must if
you want to have a simple API *and* XPath *and* good performance.

http://codespeak.net/lxml/

The API is not W3C-DOM compatible, but that's rather a plus IMHO.

Stefan
Jun 25 '07 #3
On 25 Jun, 02:04, Bruno Barberi Gnecco
<brunobgDELETET...@users.sourceforge.netwrote:
I've found a lot of XML libraries for Python. Any advices on which
one to use (or *not* to use)? My requirements are: support for XPath,
stability (a must, segfaults are not an option), with DOM API and good
performance desirable.
You might be interested in libxml2dom:

http://www.python.org/pypi/libxml2dom

It uses libxml2 under the covers, meaning that it has good performance
and supports XPath, but I can't always guarantee stability: libxml2
can get quite upset in some situations, but I've worked fairly hard to
avoid triggering them. The module API is similar to PyXML/minidom and
I've found some time to add minimal support for DOM events and SVG,
although there's a long way to go in both of these areas. This is a
project with just me as the developer, although there are a number of
helpful users who have kindly provided bug reports and suggestions for
improvements over the years.

Paul

Jun 25 '07 #4
On Jun 25, 3:47 am, Stefan Behnel <stefan.behnel-n05...@web.dewrote:
kyoso...@gmail.com wrote:
On Jun 24, 7:04 pm, Bruno Barberi Gnecco
<brunobgDELETET...@users.sourceforge.netwrote:
I've found a lot of XML libraries for Python. Any advices on which
one to use (or *not* to use)? My requirements are: support for XPath,
stability (a must, segfaults are not an option), with DOM API and good
performance desirable.
I use the minidom module for most of my XML work, but I don't think it
has much in the way of XPath. I think lxml might work better for that
sort of thing and I think it's part of ElementTree:
http://codespeak.net/lxml/dev/objectify.html

lxml is not part of ElementTree (only mostly compatible), but it's a must if
you want to have a simple API *and* XPath *and* good performance.

http://codespeak.net/lxml/

The API is not W3C-DOM compatible, but that's rather a plus IMHO.

Stefan
Oops, sorry about the mis-information. I mis-read http://effbot.org/zone/element-index.htm

Mike

Jun 25 '07 #5
Paul Boddie wrote:
On 25 Jun, 02:04, Bruno Barberi Gnecco
<brunobgDELETET...@users.sourceforge.netwrote:
> I've found a lot of XML libraries for Python. Any advices on which
one to use (or *not* to use)? My requirements are: support for XPath,
stability (a must, segfaults are not an option), with DOM API and good
performance desirable.

You might be interested in libxml2dom:

http://www.python.org/pypi/libxml2dom

It uses libxml2 under the covers, meaning that it has good performance
and supports XPath, but I can't always guarantee stability: libxml2
can get quite upset in some situations, but I've worked fairly hard to
avoid triggering them.
True, that's actually pretty hard work. lxml also does loads of stuff under
the hood to keep libxml2 happy. But that's what a good Python wrapper is for:
keep the people who use it from worrying about segfaults and memory management
and let them concentrate on their own problems.

It's more important to make the users happy than the libs. :)

Stefan
Jun 25 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

133 posts views Thread by Jane Withnolastname | last post: by
29 posts views Thread by guru.slt | last post: by
17 posts views Thread by clintonG | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.