I'm using python version 2.7.3.
test.txt:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<test>The tag <StackOverflow> is good to bring up at parties.</test>
</root>
Result:
>>> import xml.etree.ElementTree as ET
>>> e = ET.parse('test.txt')
>>> root = e.getroot()
>>> print root.find('test').text
The tag <StackOverflow> is good to bring up at parties.
As you can see, the parser must have changed the <
's to <
's etc.
What I'd like to see:
The tag <StackOverflow> is good to bring up at parties.
Untouched, raw text. Sometimes I really like it raw. Uncooked.
I'd like to use this text as-is for display within HTML, therefore I don't want an XML parser to mess with it.
Do I have to re-escape each string or can there be another way?