ANN: ElementTree 1.2 final (june 18, 2004)
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. The 1.2 release adds limited support for XPath and XInclude, and also fixes a number of serialization bugs, mostly related to extensive use of namespaces and unicode in tags and attribute names. For a complete list of changes, see the CHANGES document in the source kit. You can get the ElementTree toolkit from: http://effbot.org/downloads Documentation, articles, and some code samples (including an XML-RPC unmarshaller in 16 lines) are available from: http://effbot.org/zone/element.htm enjoy /F
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.
participants (2)
-
Edward C. Jones -
Fredrik Lundh