I\'m using python version 2.7.3.
test.txt:
The tag &am
import xml.etree.ElementTree as ET
e = ET.parse('test.txt')
root = e.getroot()
print(ET.tostring(root.find('test')))
yields
<test>The tag <StackOverflow> is good to bring up at parties.</test>
Alternatively, you could escape the text with saxutils.escape:
import xml.sax.saxutils as saxutils
print(saxutils.escape(root.find('test').text))
yields
The tag <StackOverflow> is good to bring up at parties.