Differences between revisions 29 and 30
Revision 29 as of 2010-06-22 14:33:25
Size: 5206
Editor: 27-58-139-94
Comment: Arranging lists order to meet editorial guidelines: lists are now sorted by ascending alphabetical order , a-z,0-9 using the neutral URL for sorting. Added missing pointer to pyxsd and generate DS
Revision 30 as of 2010-08-25 00:14:46
Size: 5210
Editor: 213
Comment: SAX is not a W3C spec
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
 * an event-driven XML parser compatible with the W3C SAX standard:  * an event-driven XML parser implementing SAX, the Simple API for XML:

Python and XML

A variety of XML processing solutions are available for Python. This page attempts, at the very least, to list the most actively developed or most easily available.

Packages in the standard library

The standard library has a number of tools available, which fall into mainly three categories:

  • a pythonesque, simple-to-use and very fast XML tree library:
    • ElementTree - the xml.etree package (new in Python 2.5 but available for older versions)

  • an event-driven XML parser implementing SAX, the Simple API for XML:
    • Sax - the xml.sax package

  • XML tree libraries that adhere to the W3C DOM standard:
    • MiniDom - the xml.dom.minidom package

    • PullDom - the xml.dom.pulldom package

The DOM and SAX packages have the advantage of being compatible to W3C standard APIs, so users who are already familiar with these APIs can use them without learning too many new things. Everyone else should start with the more pythonic ElementTree library, which is very well integrated into the Python language, and therefore very easy to learn and use.

External packages

A long list of special purpose and general purpose Python XML packages is available from PyPI. The following is a choice of major tools that support a broader set of XML features.

Pythonic tools

  • lxml - a pythonic, ElementTree-compatible binding for the libxml2 and libxslt libraries that comes with all sorts of powerful XML (and HTML) tools, well integrated into an easy-to-use Python API

  • lxml.objectify - a Python object API for XML based on lxml

  • PyXSD - an XML Schema mapping too (somewhat dated, last released in 2006)

  • generateDS - generates Python data structures (for example, class definitions) from an XML Schema document

  • Amara 2.x - Amara provides tools you can trust to conform with XML standards without losing the familiar Python feel

W3C DOM-like libraries

  • PyXML - external add-on to Python's original XML support - (no longer maintained)

  • itools.xml - itools provides XML processing support in a fashion similar to that of PullDom

  • libxml2dom - PyXML-style API for the libxml2 Python bindings

  • qtxmldom - PyXML-style API for the qtxml Python bindings

  • 4Suite - a framework for XML (and RDF) processing

XPath Support

  • py-dom-xpath - pure Python XPath implementation for use with DOM libraries

  • lxml - lxml has standards compliant XPath 1.0 support based on libxml2. It also supports the EXSLT extensions (including Python regular expressions) and allows calling Python functions from within XPath expressions.

  • Amara 2.x - Amara exposes an API to fully-compliant XPath (including EXSLT)

XSLT Support

If not mentioned otherwise, this means XSLT 1.0, not XSLT 2.0.

  • lxml has excellent (and easy-to-use) XSLT support that is based on libxslt. It also supports calling into Python code from XSL transformations through both XPath and XSLT extensions.

  • XSLTools - XSL transformations on top of libxslt and libxml2dom, with added Web development support

  • Some tools linked from the XQuery homepage provide Python bindings for their XSLT2 and XPath2 implementations

  • Amara 2.x - Amara exposes an API to fully-compliant XSLT (including EXSLT)

XML-based Communications

  • jabber.py - a Python module for the jabber instant messaging protocol

  • PyXMPP - a Python XMPP (RFC 3920,3921) and Jabber implementation

  • xmpppy - a Python library that is targeted to provide easy scripting with Jabber

Web Services

Object Serialization in XML

  • pyxser - a Python extension to serialize/deserialize Python objects into XML

Books and Articles


Editorial Notes

The above lists should be arranged in ascending alphabetical order - please respect this when adding new entries. When specifying release dates please use the format YYYY-MM-DD.

PythonXml (last edited 2012-01-11 01:11:25 by c-66-41-60-82)

Unable to edit the page? See the FrontPage for instructions.