tree = et.fromstring(xmltext)
for fruit in tree.xpath('//fruit'):
    fruit.text = 'rotten %s' % (fruit.text,)
print(et.tostring(tree, pretty_print=True))
Is there an easy way to manipulate XML documents in Python?