summaryrefslogtreecommitdiff
path: root/doc/main.txt
blob: 69f037cdf729fe8a09aeb079d24e9043aab86e1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
lxml
====

.. meta::
  :description: lxml - the most feature-rich and easy-to-use library for working with XML and HTML in the Python language
  :keywords: Python, XML, HTML, lxml, simple, ElementTree, etree, objectify, parsing, validation, XPath, XSLT

.. class:: pagequote

| `» lxml takes all the pain out of XML. « <http://thread.gmane.org/gmane.comp.python.lxml.devel/3252/focus=3258>`_
| Stephan Richter

.. class:: eyecatcher

     lxml is the most feature-rich
     and easy-to-use library
     for working with XML and HTML
     in the Python language.

.. 
   1  Introduction
   2  Documentation
   3  Download
   4  Mailing list
   5  Bug tracker
   6  License
   7  Old Versions


Introduction
------------

lxml is a Pythonic binding for the libxml2_ and libxslt_ libraries.  It is
unique in that it combines the speed and feature completeness of these
libraries with the simplicity of a native Python API, mostly compatible but
superior to the well-known ElementTree_ API.  See the introduction_ for more
information about background and goals.  Some common questions are answered in
the FAQ_.

For commercial consulting and customisations, please `contact Stefan Behnel`_.

.. _`contact Stefan Behnel`: http://scoder.behnel.de/
.. _libxml2: http://xmlsoft.org
.. _libxslt: http://xmlsoft.org/XSLT

.. _introduction: intro.html
.. _FAQ:          FAQ.html


Documentation
-------------

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>`_.

* ElementTree:

  * `ElementTree API`_

  * compatibility_ and differences of lxml.etree

  * `benchmark results`_

* lxml.etree:

  * the `lxml.etree Tutorial`_

  * `lxml.etree specific API`_ documentation

  * the `generated API documentation`_ as a reference

  * parsing_ and validating_ XML

  * `XPath and XSLT`_ support

  * Python `extension functions`_ for XPath and XSLT

  * `custom 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/Pyrex 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`_.  See also the ElementTree compatibility_ overview and
the `benchmark results`_ comparing lxml to the original ElementTree_ and
cElementTree_ implementations.

Right after the `lxml.etree Tutorial`_ and the ElementTree_ documentation, the
most important place to look is the `lxml.etree specific API`_ documentation.
It describes how lxml extends the ElementTree API to expose libxml2 and
libxslt specific 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 `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
comparison.

In addition to the ElementTree API, lxml also features a sophisticated API for
`custom element classes`_.  This is a simple way to write arbitrary XML driven
APIs on top of lxml.  As of version 1.1, lxml.etree has a new `C-level API`_
that can be used to efficiently extend lxml.etree in external C modules,
including custom element class support.

.. _ElementTree:  http://effbot.org/zone/element-index.htm
.. _`ElementTree API`:  http://effbot.org/zone/element-index.htm#documentation
.. _cElementTree: http://effbot.org/zone/celementtree.htm

.. _`lxml.etree Tutorial`: tutorial.html
.. _`generated API documentation`:   api/index.html
.. _`benchmark results`: performance.html
.. _`compatibility`: compatibility.html
.. _`lxml.etree specific API`: api.html
.. _`parsing`: parsing.html
.. _`validating`: validation.html
.. _`XPath and XSLT`: xpathxslt.html
.. _`extension functions`: extensions.html
.. _`custom 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: http://www.w3.org/TR/xpath
.. _`Relax NG`: http://www.relaxng.org/
.. _`XML Schema`: http://www.w3.org/XML/Schema
.. _`XSLT`: http://www.w3.org/TR/xslt
.. _`c14n`: http://www.w3.org/TR/xml-c14n


Download
--------

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 2.3`_, released 2011-02-06
(`changes for 2.3`_).  `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 svn directly, using a command like this::

  svn co http://codespeak.net/svn/lxml/trunk lxml

You can also browse the `Subversion repository`_ through the web, or
take a look at the `Subversion history`_.  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`: http://pypi.python.org/pypi/lxml/
.. _`this key`: pubkey.asc
.. _`Older versions`: #old-versions
.. _`installation instructions`: installation.html
.. _`how to build lxml from source`: build.html
.. _`Subversion repository`: http://codespeak.net/svn/lxml/
.. _`Subversion history`: https://codespeak.net/viewvc/lxml/
.. _`latest CHANGES`: http://codespeak.net/svn/lxml/trunk/CHANGES.txt


Mailing list
------------

Questions? Suggestions? Code to contribute? We have a `mailing list`_.

You can search the archive with Gmane_ or Google_.

.. _`mailing list`: http://codespeak.net/mailman/listinfo/lxml-dev
.. _Gmane: http://blog.gmane.org/gmane.comp.python.lxml.devel
.. _Google: http://www.google.com/webhp?q=site:codespeak.net%2Fmailman%2Flistinfo%2Flxml-dev+


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`: https://launchpad.net/lxml/


License
-------

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`: http://codespeak.net/svn/lxml/trunk/doc/licenses/BSD.txt
.. _`MIT license`: http://www.opensource.org/licenses/mit-license.html


Old Versions
------------

See the web sites of lxml `1.3 <http://codespeak.net/lxml/1.3/>`_,
`2.0 <http://codespeak.net/lxml/2.0/>`_, `2.1
<http://codespeak.net/lxml/2.1/>`_, `2.2
<http://codespeak.net/lxml/2.2/>`_ and the `current stable version
<http://codespeak.net/lxml/>`_

.. `current in-development version <http://codespeak.net/lxml/dev/>`_.

.. _`PDF documentation`: lxmldoc-2.3.pdf

* `lxml 2.3beta1`_, released 2010-09-06 (`changes for 2.3beta1`_)

* `lxml 2.3alpha2`_, released 2010-07-24 (`changes for 2.3alpha2`_)

* `lxml 2.3alpha1`_, released 2010-06-19 (`changes for 2.3alpha1`_)

* `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`_)

* `lxml 2.1.5`_, released 2009-01-06 (`changes for 2.1.5`_)

* `lxml 2.1.4`_, released 2008-12-12 (`changes for 2.1.4`_)

* `lxml 2.1.3`_, released 2008-11-17 (`changes for 2.1.3`_)

* `lxml 2.1.2`_, released 2008-09-05 (`changes for 2.1.2`_)

* `lxml 2.1.1`_, released 2008-07-24 (`changes for 2.1.1`_)

* `lxml 2.1`_, released 2008-07-09 (`changes for 2.1`_)

* `lxml 2.0.11`_, released 2008-12-12 (`changes for 2.0.11`_)

* `lxml 2.0.10`_, released 2008-11-17 (`changes for 2.0.10`_)

* `lxml 2.0.9`_, released 2008-09-05 (`changes for 2.0.9`_)

* `lxml 2.0.8`_, released 2008-07-24 (`changes for 2.0.8`_)

* `lxml 2.0.7`_, released 2008-06-20 (`changes for 2.0.7`_)

* `lxml 2.0.6`_, released 2008-05-31 (`changes for 2.0.6`_)

* `lxml 2.0.5`_, released 2008-05-01 (`changes for 2.0.5`_)

* `lxml 2.0.4`_, released 2008-04-14 (`changes for 2.0.4`_)

* `lxml 2.0.3`_, released 2008-03-26 (`changes for 2.0.3`_)

* `lxml 2.0.2`_, released 2008-02-22 (`changes for 2.0.2`_)

* `lxml 2.0.1`_, released 2008-02-13 (`changes for 2.0.1`_)

* `lxml 2.0`_, released 2008-02-01 (`changes for 2.0`_)

* `lxml 1.3.6`_, released 2007-10-29 (`changes for 1.3.6`_)

* `lxml 1.3.5`_, released 2007-10-22 (`changes for 1.3.5`_)

* `lxml 1.3.4`_, released 2007-08-30 (`changes for 1.3.4`_)

* `lxml 1.3.3`_, released 2007-07-26 (`changes for 1.3.3`_)

* `lxml 1.3.2`_, released 2007-07-03 (`changes for 1.3.2`_)

* lxml 1.3.1, released 2007-07-02 (`changes for 1.3.1`_)

* `lxml 1.3`_, released 2007-06-24 (`changes for 1.3`_)

* `lxml 1.2.1`_, released 2007-02-27 (`changes for 1.2.1`_)

* `lxml 1.2`_, released 2007-02-20 (`changes for 1.2`_)

* `lxml 1.1.2`_, released 2006-10-30 (`changes for 1.1.2`_)

* `lxml 1.1.1`_, released 2006-09-21 (`changes for 1.1.1`_)

* `lxml 1.1`_, released 2006-09-13 (`changes for 1.1`_)

* `lxml 1.0.4`_, released 2006-09-09 (`changes for 1.0.4`_)

* `lxml 1.0.3`_, released 2006-08-08 (`changes for 1.0.3`_)

* `lxml 1.0.2`_, released 2006-06-27 (`changes for 1.0.2`_)

* `lxml 1.0.1`_, released 2006-06-09 (`changes for 1.0.1`_)

* `lxml 1.0`_, released 2006-06-01 (`changes for 1.0`_)

* `lxml 0.9.2`_, released 2006-05-10 (`changes for 0.9.2`_)

* `lxml 0.9.1`_, released 2006-03-30 (`changes for 0.9.1`_)

* `lxml 0.9`_,   released 2006-03-20 (`changes for 0.9`_)

* `lxml 0.8`_,   released 2005-11-03 (`changes for 0.8`_)

* `lxml 0.7`_,   released 2005-06-15 (`changes for 0.7`_)

* `lxml 0.6`_,   released 2005-05-14 (`changes for 0.6`_)

* `lxml 0.5.1`_, released 2005-04-09 (`changes for 0.5.1`_)

* `lxml 0.5`_,   released 2005-04-08

.. _`lxml 2.3`: lxml-2.3.tgz
.. _`lxml 2.3beta1`: lxml-2.3beta1.tgz
.. _`lxml 2.3alpha2`: lxml-2.3alpha2.tgz
.. _`lxml 2.3alpha1`: lxml-2.3alpha1.tgz
.. _`lxml 2.2.8`: lxml-2.2.8.tgz
.. _`lxml 2.2.7`: lxml-2.2.7.tgz
.. _`lxml 2.2.6`: lxml-2.2.6.tgz
.. _`lxml 2.2.5`: lxml-2.2.5.tgz
.. _`lxml 2.2.4`: lxml-2.2.4.tgz
.. _`lxml 2.2.3`: lxml-2.2.3.tgz
.. _`lxml 2.2.2`: lxml-2.2.2.tgz
.. _`lxml 2.2.1`: lxml-2.2.1.tgz
.. _`lxml 2.2`: lxml-2.2.tgz
.. _`lxml 2.1.5`: lxml-2.1.5.tgz
.. _`lxml 2.1.4`: lxml-2.1.4.tgz
.. _`lxml 2.1.3`: lxml-2.1.3.tgz
.. _`lxml 2.1.2`: lxml-2.1.2.tgz
.. _`lxml 2.1.1`: lxml-2.1.1.tgz
.. _`lxml 2.1`: lxml-2.1.tgz
.. _`lxml 2.0.11`: lxml-2.0.11.tgz
.. _`lxml 2.0.10`: lxml-2.0.10.tgz
.. _`lxml 2.0.9`: lxml-2.0.9.tgz
.. _`lxml 2.0.8`: lxml-2.0.8.tgz
.. _`lxml 2.0.7`: lxml-2.0.7.tgz
.. _`lxml 2.0.6`: lxml-2.0.6.tgz
.. _`lxml 2.0.5`: lxml-2.0.5.tgz
.. _`lxml 2.0.4`: lxml-2.0.4.tgz
.. _`lxml 2.0.3`: lxml-2.0.3.tgz
.. _`lxml 2.0.2`: lxml-2.0.2.tgz
.. _`lxml 2.0.1`: lxml-2.0.1.tgz
.. _`lxml 2.0`: lxml-2.0.tgz
.. _`lxml 1.3.6`: lxml-1.3.6.tgz
.. _`lxml 1.3.5`: lxml-1.3.5.tgz
.. _`lxml 1.3.4`: lxml-1.3.4.tgz
.. _`lxml 1.3.3`: lxml-1.3.3.tgz
.. _`lxml 1.3.2`: lxml-1.3.2.tgz
.. _`lxml 1.3`: lxml-1.3.tgz
.. _`lxml 1.2.1`: lxml-1.2.1.tgz
.. _`lxml 1.2`: lxml-1.2.tgz
.. _`lxml 1.1.2`: lxml-1.1.2.tgz
.. _`lxml 1.1.1`: lxml-1.1.1.tgz
.. _`lxml 1.1`: lxml-1.1.tgz
.. _`lxml 1.0.4`: lxml-1.0.4.tgz
.. _`lxml 1.0.3`: lxml-1.0.3.tgz
.. _`lxml 1.0.2`: lxml-1.0.2.tgz
.. _`lxml 1.0.1`: lxml-1.0.1.tgz
.. _`lxml 1.0`: lxml-1.0.tgz
.. _`lxml 0.9.2`: lxml-0.9.2.tgz
.. _`lxml 0.9.1`: lxml-0.9.1.tgz
.. _`lxml 0.9`: lxml-0.9.tgz
.. _`lxml 0.8`: lxml-0.8.tgz
.. _`lxml 0.7`: lxml-0.7.tgz
.. _`lxml 0.6`: lxml-0.6.tgz
.. _`lxml 0.5.1`: lxml-0.5.1.tgz
.. _`lxml 0.5`: lxml-0.5.tgz

.. _`changes for 2.3`: changes-2.3.html
.. _`changes for 2.3beta1`: changes-2.3beta1.html
.. _`changes for 2.3alpha2`: changes-2.3alpha2.html
.. _`changes for 2.3alpha1`: changes-2.3alpha1.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
.. _`changes for 2.1.5`: changes-2.1.5.html
.. _`changes for 2.1.4`: changes-2.1.4.html
.. _`changes for 2.1.3`: changes-2.1.3.html
.. _`changes for 2.1.2`: changes-2.1.2.html
.. _`changes for 2.1.1`: changes-2.1.1.html
.. _`changes for 2.1`: changes-2.1.html
.. _`changes for 2.0.11`: changes-2.0.11.html
.. _`changes for 2.0.10`: changes-2.0.10.html
.. _`changes for 2.0.9`: changes-2.0.9.html
.. _`changes for 2.0.8`: changes-2.0.8.html
.. _`changes for 2.0.7`: changes-2.0.7.html
.. _`changes for 2.0.6`: changes-2.0.6.html
.. _`changes for 2.0.5`: changes-2.0.5.html
.. _`changes for 2.0.4`: changes-2.0.4.html
.. _`changes for 2.0.3`: changes-2.0.3.html
.. _`changes for 2.0.2`: changes-2.0.2.html
.. _`changes for 2.0.1`: changes-2.0.1.html
.. _`changes for 2.0`: changes-2.0.html
.. _`changes for 1.3.6`: changes-1.3.6.html
.. _`changes for 1.3.5`: changes-1.3.5.html
.. _`changes for 1.3.4`: changes-1.3.4.html
.. _`changes for 1.3.3`: changes-1.3.3.html
.. _`changes for 1.3.2`: changes-1.3.2.html
.. _`changes for 1.3.1`: changes-1.3.1.html
.. _`changes for 1.3`: changes-1.3.html
.. _`changes for 1.2.1`: changes-1.2.1.html
.. _`changes for 1.2`: changes-1.2.html
.. _`changes for 1.1.2`: changes-1.1.2.html
.. _`changes for 1.1.1`: changes-1.1.1.html
.. _`changes for 1.1`: changes-1.1.html
.. _`changes for 1.0.4`: changes-1.0.4.html
.. _`changes for 1.0.3`: changes-1.0.3.html
.. _`changes for 1.0.2`: changes-1.0.2.html
.. _`changes for 1.0.1`: changes-1.0.1.html
.. _`changes for 1.0`: changes-1.0.html
.. _`changes for 0.9.2`: changes-0.9.2.html
.. _`changes for 0.9.1`: changes-0.9.1.html
.. _`changes for 0.9`: changes-0.9.html
.. _`changes for 0.8`: changes-0.8.html
.. _`changes for 0.7`: changes-0.7.html
.. _`changes for 0.6`: changes-0.6.html
.. _`changes for 0.5.1`: changes-0.5.1.html