Using elementtree: replacing nodes

André andre.roberge at gmail.com
Tue May 2 12:21:06 CEST 2006


Fredrik Lundh wrote:
> André wrote:
>
> > I've started using elementtree and don't understand how to use it to
> > manipulate and replace nodes.

[snip]
It was mostly the following step which I couldn`t figure out...

>     # 2) mutate the pre element
>     pre.clear()
>     pre.tag = "form"
>     pre[:] = [form]
>
[snip]

> another approach is to build a parent map; see the parent_map code
> at
>
>    http://effbot.org/zone/element.htm#the-element-type
> 


Thanks!

> </F>




More information about the Python-list mailing list