Changes in ElementTree 1.3 (preliminary)
Welcome to effbot.org!
This page describes the changes that will take place in the next ElementTree release.
You can get ElementTree development releases from the public subversion repository.
Changes from release 1.2 to 1.3
The library requires Python 2.2 or newer (this may change to 2.3 before release).
The Element class now has an extend method.
The Element class now has an iter method; this replaces the old getiterator method.
The Element class now has an itertext method; this yields all inner text parts (that is, the text attribute for the element itself, and the text and tail attributes for all subchildren, in document order).
The Element factory is now a class; you can inherit directly from Element, if you want.
The path syntax now supports attibute predicates (tag[@attrib]).
The XMLParser class allows you to override the XML file encoding.
All parser functions (parse, iterparse, XML, XMLID, fromstring, etc) take an optional parser argument.
The E element builder class may be added.
The write method has two new options; xml_declaration controls if an XML declaration should be included, default_namespace controls whether a default namespace should be used.
Removed and Deprecated Features
XMLTreeBuilder has been deprecated, use XMLParser instead.
getiterator has been deprecated, use iter instead.
getchildren has been deprecated, use direct iteration over the container instead. getchildren now gives a warning. The method will be removed in future versions.
“if elem” works as before, but now gives a warning; for portability, use explicit tests (“if len(elem)” or “if elem is not None”). The behaviour may change in future versions.
The SgmlopTreeBuilder module has been removed; for maximum performance, use cElementTree instead. You can use cElementTree’s parser with ElementTree; see below.
The SimpleXMLTreeBuilder module has been removed.
The XMLTreeBuilder module has been removed. For detailed namespace access, use iterparse instead.
The serializer is now about twice as fast on common examples. Also, the serializer now puts all namespace declarations on the topmost element.
If you have cElementTree 1.0.6 or later, you can speed up parsing by replacing ElementTree’s XMLParser class with the one from cElementTree:
import elementtree.ElementTree as ET import cElementTree # use cET to build element trees ET.XMLParser = cElementTree.XMLParser