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