ElementTree
- Posted by admin on December 7th, 2005 filed in ruby
For those not in the know ElementTree is a Python API created by Fredrik Lundh to handle XML data in a simple, clean and powerful way. However, unlike the more complicated non-pythonic modules such as SAX and DOM - it is not included in the core Python installation.
If you’ve any experience with using Python with XML you’ll know its not exactly ‘nice’. In many example scripts I’ve come across that require the parsing of XML data a class is added to perform some initial breaking down and simplification before operating on it. This lack of a simplified API can be immensely annoying when in the Python community we’re used to the Way being clear.
The way ElementTree works is elegent and its also fast. Evidence of its speed over other DOM-based modules can be seen in tests done by David Mertz - in which he also benchmarks one of his own XML parsing modules - xml.objectify.
The reasons for ElementTree not being included are largely political. To add it to the core would mean Lundh relinquishing some control of it - something which he would understandably feel uncomfortable about.
In the mean-time for those wanting simplicity in their XML operations I strongly recommend downloading, either ElementTree from the Effbot site or David’s xml_objectify.
Related











Leave a Comment