f = etree.fromstring(data)
for r in f.xpath('//r'):
    r.tail = 'DELETED' + r.tail if r.tail else 'DELETED'
etree.strip_elements(f, 'r', with_tail=False)
print(etree.tostring(f, pretty_print=True))
How can one replace an element with text in lxml?