Last active
December 16, 2015 21:39
-
-
Save evdb/5501489 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
evdb@custard-2 ~/5501489 $ python xml-test.py | |
--- running tostring | |
--- result is: | |
This is | |
some | |
text… | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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