replacing xml elements with other elements using lxml
stefan.behnel-n05pAM at web.de
Thu Aug 30 09:17:59 CEST 2007
> Ah! I figured it out. I forgot that the tree is treated like a list.
> The solution was to replace the <random> element with the first <item>
> child, then use Python's insert(i,x) function to insert elements after
> the first one.
You could also use slicing, something like:
parent[2:3] = child[1:5]
> lxml rocks!
I know, but it feels good to read it once in a while. :)
More information about the Python-list