Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
Project description
lxml is a Pythonic, mature binding for the libxml2 and libxslt libraries. It provides safe and convenient access to these libraries using the ElementTree API.
It extends the ElementTree API significantly to offer support for XPath, RelaxNG, XML Schema, XSLT, C14N and much more.
To contact the project, go to the project home page or see our bug tracker at https://launchpad.net/lxml
In case you want to use the current in-development version of lxml, you can get it from the github repository at https://github.com/lxml/lxml . Note that this requires Cython to build the sources, see the build instructions on the project home page. To the same end, running easy_install lxml==dev will install lxml from https://github.com/lxml/lxml/tarball/master#egg=lxml-dev if you have an appropriate version of Cython installed.
After an official release of a new stable series, bug fixes may become available at https://github.com/lxml/lxml/tree/lxml-4.4 . Running easy_install lxml==4.4bugfix will install the unreleased branch state from https://github.com/lxml/lxml/tarball/lxml-4.4#egg=lxml-4.4bugfix as soon as a maintenance branch has been established. Note that this requires Cython to be installed at an appropriate version for the build.
4.4.0 (2019-07-27)
Features added
Element.clear() accepts a new keyword argument keep_tail=True to clear everything but the tail text. This is helpful in some document-style use cases.
When creating attributes or namespaces from a dict in Python 3.6+, lxml now preserves the original insertion order of that dict, instead of always sorting the items by name. A similar change was made for ElementTree in CPython 3.8. See https://bugs.python.org/issue34160
Integer elements in lxml.objectify implement the __index__() special method.
GH#269: Read-only elements in XSLT were missing the nsmap property. Original patch by Jan Pazdziora.
ElementInclude can now restrict the maximum inclusion depth via a max_depth argument to prevent content explosion. It is limited to 6 by default.
The target object of the XMLParser can have start_ns() and end_ns() callback methods to listen to namespace declarations.
The TreeBuilder has new arguments comment_factory and pi_factory to pass factories for creating comments and processing instructions, as well as flag arguments insert_comments and insert_pis to discard them from the tree when set to false.
A C14N 2.0 implementation was added as etree.canonicalize(), a corresponding C14NWriterTarget class, and a c14n2 serialisation method.
Bugs fixed
When writing to file paths that contain the URL escape character ‘%’, the file path could wrongly be mangled by URL unescaping and thus write to a different file or directory. Code that writes to file paths that are provided by untrusted sources, but that must work with previous versions of lxml, should best either reject paths that contain ‘%’ characters, or otherwise make sure that the path does not contain maliciously injected ‘%XX’ URL hex escapes for paths like ‘../’.
Assigning to Element child slices with negative step could insert the slice at the wrong position, starting too far on the left.
Assigning to Element child slices with overly large step size could take very long, regardless of the length of the actual slice.
Assigning to Element child slices of the wrong size could sometimes fail to raise a ValueError (like a list assignment would) and instead assign outside of the original slice bounds or leave parts of it unreplaced.
The comment and pi events in iterwalk() were never triggered, and instead, comments and processing instructions in the tree were reported as start elements. Also, when walking an ElementTree (as opposed to its root element), comments and PIs outside of the root element are now reported.
LP#1827833: The RelaxNG compact syntax support was broken with recent versions of rnc2rng.
LP#1758553: The HTML elements source and track were added to the list of empty tags in lxml.html.defs.
Registering a prefix other than “xml” for the XML namespace is now rejected.
Failing to write XSLT output to a file could raise a misleading exception. It now raises IOError.
Other changes
Support for Python 3.4 was removed.
When using Element.find*() with prefix-namespace mappings, the empty string is now accepted to define a default namespace, in addition to the previously supported None prefix. Empty strings are more convenient since they keep all prefix keys in a namespace dict strings, which simplifies sorting etc.
The ElementTree.write_c14n() method has been deprecated in favour of the long preferred ElementTree.write(f, method="c14n"). It will be removed in a future release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for lxml-4.4.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e86e5df4a8edd6f725f3c76f1d45e046d4f3aa40478092e4f5f373ad1f526e2 |
|
MD5 | 1f1c82fb8032ca54074c9bea181a90e6 |
|
BLAKE2b-256 | 21baca19058e1ae455c0425f72bd9fe1a0493e89f19f494b46a5c88867371def |
Hashes for lxml-4.4.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5a61e9c2322b45f259909a02b76bc98c4641214e22a37191d00c151aa9cdb9a |
|
MD5 | d8722ab1271c598a4c66dffa416f9485 |
|
BLAKE2b-256 | f034bd9aaf095af93648bf9e2738b1105460e2687c2202f24b8046cf9bca6895 |
Hashes for lxml-4.4.0-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f840dddded8b046edc774c88ed8d2442cdb231a68894c42c74e3a809450fae76 |
|
MD5 | 10f0c0d779463899d45fcf9f649726f4 |
|
BLAKE2b-256 | 367821cab1b4f269e8c3bb88e93016b16df023a69c73e31e7adafb2c125b30e7 |
Hashes for lxml-4.4.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fef86edfa2f146b4b0ae2c6c05c3e4a8f3388b3655eafbc4aab3247f4dabb24 |
|
MD5 | d60c382e25db7c5f69aec99ea7c5f5f3 |
|
BLAKE2b-256 | 05feffc5c23db9afa827660290e03d22f6736f9028b85eb8cf0dba15aff54356 |
Hashes for lxml-4.4.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da5c48ec9f8d8b5df42d328b6d1fb8d9413cd664a2367ef4f6f7cc48ee5b82c0 |
|
MD5 | 435d840e6e3483ba88f160db27528e1c |
|
BLAKE2b-256 | 90e2fa3d40b4de170d35c3f6b4cc4c25ef0eaea93d08f598a4d7c0d61bd2886b |
Hashes for lxml-4.4.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43dac60d10341d3e56be089cd0798b70e70d45ce32279f4c3190d8cbd71350e4 |
|
MD5 | e328ddbe005319ff7fce7230c1a465e2 |
|
BLAKE2b-256 | b4329ce1edcfd91ffbae0af3836a9ae3fe2d72f6c5f8b6980c7c5294935a0266 |
Hashes for lxml-4.4.0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75d731af05bf40f808d7716e0d26b4b02913402f861c032ce8c36efca350ae72 |
|
MD5 | 658bf66b29382bf940f7fbc1c35e2a79 |
|
BLAKE2b-256 | df04ec2031f033055cf496a781b43a21cb86d2df23d430aae9af3ded436b6b1e |
Hashes for lxml-4.4.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5033cf606a7cb559db967689b1b2e743994000f783607ba4c484e90917395ad7 |
|
MD5 | 511ddcd0101620b0e10bb5d4cfa884bf |
|
BLAKE2b-256 | b4ddc76154fe8c36fa82c041856982955545964e490522a5358b99992faef250 |
Hashes for lxml-4.4.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f77061c20b4f32b1cf39e8f661c74e966344084c996e7b23c3a94e472461df0 |
|
MD5 | 6b7a1f82ab8350328e889106da20bc20 |
|
BLAKE2b-256 | 31fc93037048f56f4afa6e0327c602d1919847580aa12f2642a5f91b18306086 |
Hashes for lxml-4.4.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1c2f67df727034f94ccb590142d1d110f3dd38f638a4f1567fdd9f39892ba05 |
|
MD5 | 865f96410ed7e1169c61c51f1bae4d1b |
|
BLAKE2b-256 | e70e526881ee1cc4a30dcd94179f938eb817cbd4dafef692c8af414ab79b7eb6 |
Hashes for lxml-4.4.0-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f163c8844db4ed06a230ef092e2461ad01830972a896b8f3cf8b5bac70ae85d |
|
MD5 | 04bb1cf8bfde5cc28c30f7858769bec5 |
|
BLAKE2b-256 | 035903a220ffdebaf28554b5037d746b35fd269ff1fac949588b190bd884f791 |
Hashes for lxml-4.4.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db2794bad21b7b30b6849b4e1537171cae8a7087711d958d69c233470dc612e7 |
|
MD5 | f1379c5bb0ea81f7b867fdbd4dfc6367 |
|
BLAKE2b-256 | 00ed91ce1a76986f554c68836de48f166f395344668cb87c93f449cb2fbc1eed |
Hashes for lxml-4.4.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b6d49d0a26fe8207df8dd27c40b75be4deb2277173903aa76ec3e82df77cbe7 |
|
MD5 | 4803f606b2b22c1a8f2e9b886283eecf |
|
BLAKE2b-256 | 611028ffbc2a9b561b42f0a173ae6471f7ec8c4abc9350d003554c699f2b2389 |
Hashes for lxml-4.4.0-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 350333190052bbfbc3222b1805b59b7979d7276e57af2257367e15a2db27082d |
|
MD5 | 8f34c3c728daf1ee7f37fac59235f277 |
|
BLAKE2b-256 | ad55c08f56e64b6e66349984029a38f3d9948eca90834ae0a195a2d5d7e6e0a0 |
Hashes for lxml-4.4.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 092237cfe4ece074401b75001a2e525fa6e1fb9d40fee8b7b132b1947d3bd2f8 |
|
MD5 | 400798c0c05bb2f7c0cfb75de52a927f |
|
BLAKE2b-256 | f7ae26da3bd4970b65d0a0d6bb1bbd87aceaf896fe0225c882a269cc38fc1fa1 |
Hashes for lxml-4.4.0-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b33ec641309bcea40c76c1b105f988e4e8f9a2f1ee1486aa5c0eeef33956c9bb |
|
MD5 | 40785775cc9954b426d32fe4b61e749b |
|
BLAKE2b-256 | 55fa5eafdcfdbd66d197649945d3b963aea1919f5f1d2994f7bff3663bd10a31 |
Hashes for lxml-4.4.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06e5599b9c54f797a3c0f384c67705a0d621031007aa2400a6c7d17300fdb995 |
|
MD5 | 726cce838467490239a2c8c5769d3b65 |
|
BLAKE2b-256 | 797fc7eadf33914730b969d88066f698953ce06b261f3cb3be870bd9c00d7349 |