[XML-SIG] my own entity defs when parsing with etree?

Josh English joshua.r.english at gmail.com
Mon Jul 13 02:24:25 CEST 2009

I gave up on Entities ages ago, but thought I'd try it after seeing your link.

I tried this simple code:

from elementtree import ElementTree as ET

p = ET.XMLParser()

p.entity["me"] = "Josh"

text = """<test>&me;</test>"""


e = p.close()

print e

And got an error:

>pythonw -u "ETParserWithEntities.py"
Traceback (most recent call last):
  File "ETParserWithEntities.py", line 9, in <module>
  File "C:\Python26\lib\site-packages\elementtree\ElementTree.py",
line 1524, in feed
  File "C:\Python26\lib\site-packages\elementtree\ElementTree.py",
line 1426, in _raiseerror
    raise err
elementtree.ElementTree.ParseError: undefined entity: line 1, column 6
>Exit code: 1

As far as I can tell, the XMLParser is using pyexpat, which only comes
as a .pyd file, so I can't look into this.

Any ideas?

Windows XP, Python 2.6, elementtree 1v3a2

Josh English

Josh English
Joshua.R.English at gmail.com

More information about the XML-SIG mailing list