Skip to content

Instantly share code, notes, and snippets.

@msikma
Created November 5, 2015 15:02
Show Gist options
  • Save msikma/3d5334e022967c65e2b0 to your computer and use it in GitHub Desktop.
Save msikma/3d5334e022967c65e2b0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import xml.etree.ElementTree as ET
xml = '''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE TestXml [
<!ELEMENT TestXml (TestNode*)>
<!ELEMENT TestNode (#PCDATA)>
<!ENTITY testent "test entity">
]>
<TestXml>
<TestNode>&testent;</TestNode>
</TestXml>
'''
tree = ET.fromstring(xml)
# prints: test entity
# but I want: &testent;
print(tree[0].text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment