Skip to content

Instantly share code, notes, and snippets.

@evdb
Last active December 16, 2015 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evdb/5501489 to your computer and use it in GitHub Desktop.
Save evdb/5501489 to your computer and use it in GitHub Desktop.
evdb@custard-2 ~/5501489 $ python xml-test.py
--- running tostring
--- result is:
This is
some
text…
import xml.etree.ElementTree as ET
xml = open('xml-test.xml').read()
root = ET.fromstring(xml)
foo = root.find('foo')
print "--- running tostring"
full = ET.tostring(foo, method="text", encoding="utf8")
print "--- result is:"
print full
<outer>
<foo>
This is
<i>some</i>
text…
</foo>
</outer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment