Q:

How can i do replace a child element(s) in ElementTree

I want to replace child elements from one tree to another , based on some criteria. I can do this using Comprehension ? But how do we replace element in ElementTree?

A:

You can't replace an element from the ElementTree you can only work with Element.
Even when you call ElementTree.find() it's just a shortcut for getroot().find().
So you really need to:

extract the parent element
use comprehension (or whatever you like) on that parent element

The extraction of the parent element can be easy if your target is a root sub-element (just call getroot()) otherwise you'll have to find it.

