ANN: ElementTree 1.2 final (june 18, 2004)

Edward C. Jones edcjones@erols.com
Sat, 19 Jun 2004 12:17:11 -0400


Fredrik Lundh wrote:
> The Element type is a simple but flexible container object, designed
> to store hierarchical data structures, such as simplified XML infosets,
> in memory.  The ElementTree package provides a Python implementation
> of this type, plus code to serialize element trees to and from XML files.

I would like to suggest some additions to Element:

walk: A generator that walks a tree in depth-first order. I think this
     is the same as "getiterator" but the docs are confusing.

reverse_walk: Like walk but in the reverse order.

walkaround: Walks around the outside of a tree. Each non-terminal node
     is visited twice. Each node should have a attribute whose values can
     be NONE, DONE, FIRST, SECOND, and LEAF.

kill: Removes a node from a tree. It is replaced by its children.

prettyprint: Prints a tree with each node indented according to its
     depth.