import copy
import lxml.etree
xml1 = (
    '<root><attr><chaos foo="0"/></attr><attr><arena foo="1"/></attr></root>')
xml2 = '<tree><attr><one/></attr><attr><two/></attr></tree>'
tree1 = lxml.etree.fromstring(xml1)
tree2 = lxml.etree.fromstring(xml2)
replacements = tree1.xpath('//attr')
replacements.reverse()
for attr in tree2.xpath('//attr'):
    node = replacements.pop()
attr.getparent().replace(attr, copy.deepcopy(node))
print(lxml.etree.tostring(tree2))
search/replace content of xml