Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
316 lines (227 sloc) 10.8 KB
.. meta::
:description: lxml - the most feature-rich and easy-to-use library for processing XML and HTML in the Python language
:keywords: Python XML, XML processing, HTML, lxml, simple XML, ElementTree, etree, lxml.etree, objectify, XML parsing, XML validation, XPath, XSLT
.. class:: pagequote
| `» lxml takes all the pain out of XML. « <>`_
| Stephan Richter
.. class:: eyecatcher
lxml is the most feature-rich
and easy-to-use library
for processing XML and HTML
in the Python language.
1 Introduction
2 Documentation
3 Download
4 Mailing list
5 Bug tracker
6 License
7 Old Versions
The lxml XML toolkit is a Pythonic binding for the C libraries
libxml2_ and libxslt_. It is unique in that it combines the speed and
XML feature completeness of these libraries with the simplicity of a
native Python API, mostly compatible but superior to the well-known
ElementTree_ API. The latest release works with all CPython versions
from 2.4 to 3.3. See the introduction_ for more information about
background and goals of the lxml project. Some common questions are
answered in the FAQ_.
.. _libxml2:
.. _libxslt:
.. _introduction: intro.html
.. _FAQ: FAQ.html
The complete lxml documentation is available for download as `PDF
documentation`_. The HTML documentation from this web site is part of
the normal `source download <#download>`_.
* Tutorials:
* the `lxml.etree tutorial for XML processing`_
* John Shipman's tutorial on `Python XML processing with lxml`_
* Fredrik Lundh's `tutorial for ElementTree`_
* ElementTree:
* `ElementTree API`_
* compatibility_ and differences of lxml.etree
* `ElementTree performance`_ characteristics and comparison
* lxml.etree:
* `lxml.etree specific API`_ documentation
* the `generated API documentation`_ as a reference
* parsing_ and validating_ XML
* `XPath and XSLT`_ support
* Python `XPath extension functions`_ for XPath and XSLT
* `custom XML element classes`_ for custom XML APIs (see `EuroPython 2008 talk`_)
* a `SAX compliant API`_ for interfacing with other XML tools
* a `C-level API`_ for interfacing with external C/Cython modules
* lxml.objectify:
* `lxml.objectify`_ API documentation
* a brief comparison of `objectify and etree`_
lxml.etree follows the ElementTree_ API as much as possible, building
it on top of the native libxml2 tree. If you are new to ElementTree,
start with the `lxml.etree tutorial for XML processing`_. See also the
ElementTree compatibility_ overview and the `ElementTree performance`_
page comparing lxml to the original ElementTree_ and cElementTree_
Right after the `lxml.etree tutorial for XML processing`_ and the
ElementTree_ documentation, the next place to look is the `lxml.etree
specific API`_ documentation. It describes how lxml extends the
ElementTree API to expose libxml2 and libxslt specific XML
functionality, such as XPath_, `Relax NG`_, `XML Schema`_, XSLT_, and
`c14n`_. Python code can be called from XPath expressions and XSLT
stylesheets through the use of `XPath extension functions`_. lxml
also offers a `SAX compliant API`_, that works with the SAX support in
the standard library.
There is a separate module `lxml.objectify`_ that implements a data-binding
API on top of lxml.etree. See the `objectify and etree`_ FAQ entry for a
In addition to the ElementTree API, lxml also features a sophisticated
API for `custom XML element classes`_. This is a simple way to write
arbitrary XML driven APIs on top of lxml. lxml.etree also has a
`C-level API`_ that can be used to efficiently extend lxml.etree in
external C modules, including fast custom element class support.
.. _ElementTree:
.. _`ElementTree API`:
.. _cElementTree:
.. _`tutorial for ElementTree`:
.. _`lxml.etree tutorial for XML processing`: tutorial.html
.. _`Python XML processing with lxml`:
.. _`generated API documentation`: api/index.html
.. _`ElementTree performance`: performance.html
.. _`compatibility`: compatibility.html
.. _`lxml.etree specific API`: api.html
.. _`parsing`: parsing.html
.. _`validating`: validation.html
.. _`XPath and XSLT`: xpathxslt.html
.. _`XPath extension functions`: extensions.html
.. _`custom XML element classes`: element_classes.html
.. _`SAX compliant API`: sax.html
.. _`C-level API`: capi.html
.. _`lxml.objectify`: objectify.html
.. _`objectify and etree`: FAQ.html#what-is-the-difference-between-lxml-etree-and-lxml-objectify
.. _`EuroPython 2008 talk`: s5/lxml-ep2008.html
.. _XPath:
.. _`Relax NG`:
.. _`XML Schema`:
.. _`XSLT`:
.. _`c14n`:
The best way to download lxml is to visit `lxml at the Python Package
Index`_ (PyPI). It has the source that compiles on various platforms.
The source distribution is signed with `this key`_. Binary builds for
MS Windows usually become available through PyPI a few days after a
source release. If you can't wait, consider trying a less recent
release version first.
The latest version is `lxml 3.0beta1`_, released 2012-09-26
(`changes for 3.0beta1`_). `Older versions`_ are listed below.
Please take a look at the `installation instructions`_!
This complete web site (including the generated API documentation) is
part of the source distribution, so if you want to download the
documentation for offline use, take the source archive and copy the
``doc/html`` directory out of the source tree.
It's also possible to check out the latest development version of lxml
from github directly, using a command like this (assuming you use hg
and have hg-git installed)::
hg clone lxml
You can also browse the `source repository`_ and its history through
the web. Please read `how to build lxml from source`_ first. The
`latest CHANGES`_ of the developer version are also accessible. You
can check there if a bug you found has been fixed or a feature you
want has been implemented in the latest trunk version.
.. _`lxml at the Python Package Index`:
.. _`this key`: pubkey.asc
.. _`Older versions`: #old-versions
.. _`installation instructions`: installation.html
.. _`how to build lxml from source`: build.html
.. _`source repository`:
.. _`latest CHANGES`:
Mailing list
Questions? Suggestions? Code to contribute? We have a `mailing list`_.
You can search the archive with Gmane_ or Google_.
.. _`mailing list`:
.. _Gmane:
.. _Google:
Bug tracker
lxml uses the `launchpad bug tracker`_. If you are sure you found a
bug in lxml, please file a bug report there. If you are not sure
whether some unexpected behaviour of lxml is a bug or not, please
check the documentation and ask on the `mailing list`_ first. Do not
forget to search the archive (e.g. with Gmane_)!
.. _`launchpad bug tracker`:
The lxml library is shipped under a `BSD license`_. libxml2 and libxslt2
itself are shipped under the `MIT license`_. There should therefore be no
obstacle to using lxml in your codebase.
.. _`BSD license`:
.. _`MIT license`:
Old Versions
See the web sites of lxml
`1.3 <>`_,
`2.0 <>`_,
`2.1 <>`_,
`2.2 <>`_
`2.3 <>`_
and the `latest in-development version <>`_.
.. _`PDF documentation`: lxmldoc-3.0beta1.pdf
* `lxml 3.0alpha2`_, released 2012-08-23 (`changes for 3.0alpha2`_)
* `lxml 3.0alpha1`_, released 2012-07-31 (`changes for 3.0alpha1`_)
* `lxml 2.3.5`_, released 2012-07-31 (`changes for 2.3.5`_)
* `lxml 2.3.4`_, released 2012-03-26 (`changes for 2.3.4`_)
* `lxml 2.3.3`_, released 2012-01-04 (`changes for 2.3.3`_)
* `lxml 2.3.2`_, released 2011-11-11 (`changes for 2.3.2`_)
* `lxml 2.3.1`_, released 2011-09-25 (`changes for 2.3.1`_)
* `lxml 2.3`_, released 2011-02-06 (`changes for 2.3`_)
* `lxml 2.2.8`_, released 2010-09-02 (`changes for 2.2.8`_)
* `lxml 2.2.7`_, released 2010-07-24 (`changes for 2.2.7`_)
* `lxml 2.2.6`_, released 2010-03-02 (`changes for 2.2.6`_)
* `lxml 2.2.5`_, released 2010-02-28 (`changes for 2.2.5`_)
* `lxml 2.2.4`_, released 2009-11-11 (`changes for 2.2.4`_)
* `lxml 2.2.3`_, released 2009-10-30 (`changes for 2.2.3`_)
* `lxml 2.2.2`_, released 2009-06-21 (`changes for 2.2.2`_)
* `lxml 2.2.1`_, released 2009-06-02 (`changes for 2.2.1`_)
* `lxml 2.2`_, released 2009-03-21 (`changes for 2.2`_)
* `older releases <>`_
.. _`lxml 3.0beta1`: /files/lxml-3.0beta1.tgz
.. _`lxml 3.0alpha2`: /files/lxml-3.0alpha2.tgz
.. _`lxml 3.0alpha1`: /files/lxml-3.0alpha1.tgz
.. _`lxml 2.3.6`: /files/lxml-2.3.6.tgz
.. _`lxml 2.3.5`: /files/lxml-2.3.5.tgz
.. _`lxml 2.3.4`: /files/lxml-2.3.4.tgz
.. _`lxml 2.3.3`: /files/lxml-2.3.3.tgz
.. _`lxml 2.3.2`: /files/lxml-2.3.2.tgz
.. _`lxml 2.3.1`: /files/lxml-2.3.1.tgz
.. _`lxml 2.3`: /files/lxml-2.3.tgz
.. _`lxml 2.2.8`: /files/lxml-2.2.8.tgz
.. _`lxml 2.2.7`: /files/lxml-2.2.7.tgz
.. _`lxml 2.2.6`: /files/lxml-2.2.6.tgz
.. _`lxml 2.2.5`: /files/lxml-2.2.5.tgz
.. _`lxml 2.2.4`: /files/lxml-2.2.4.tgz
.. _`lxml 2.2.3`: /files/lxml-2.2.3.tgz
.. _`lxml 2.2.2`: /files/lxml-2.2.2.tgz
.. _`lxml 2.2.1`: /files/lxml-2.2.1.tgz
.. _`lxml 2.2`: /files/lxml-2.2.tgz
.. _`changes for 3.0beta1`: /changes-3.0beta1.html
.. _`changes for 3.0alpha2`: /changes-3.0alpha2.html
.. _`changes for 3.0alpha1`: /changes-3.0alpha1.html
.. _`changes for 2.3.6`: /changes-2.3.6.html
.. _`changes for 2.3.5`: /changes-2.3.5.html
.. _`changes for 2.3.4`: /changes-2.3.4.html
.. _`changes for 2.3.3`: /changes-2.3.3.html
.. _`changes for 2.3.2`: /changes-2.3.2.html
.. _`changes for 2.3.1`: /changes-2.3.1.html
.. _`changes for 2.3`: /changes-2.3.html
.. _`changes for 2.2.8`: /changes-2.2.8.html
.. _`changes for 2.2.7`: /changes-2.2.7.html
.. _`changes for 2.2.6`: /changes-2.2.6.html
.. _`changes for 2.2.5`: /changes-2.2.5.html
.. _`changes for 2.2.4`: /changes-2.2.4.html
.. _`changes for 2.2.3`: /changes-2.2.3.html
.. _`changes for 2.2.2`: /changes-2.2.2.html
.. _`changes for 2.2.1`: /changes-2.2.1.html
.. _`changes for 2.2`: /changes-2.2.html
Something went wrong with that request. Please try again.