Re: my own entity defs when parsing with etree?

Josh English <[email protected]> Sun, 12 Jul 2009 17:24:25 -0700
Newsgroups gmane.comp.python.xml
Message-ID <[email protected]>
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>"""

p.feed(text)

e = p.close()

print e
ET.dump(e)

And got an error:

>pythonw -u "ETParserWithEntities.py"
Traceback (most recent call last):
  File "ETParserWithEntities.py", line 9, in <module>
    p.feed(text)
  File "C:\Python26\lib\site-packages\elementtree\ElementTree.py",
line 1524, in feed
    self._raiseerror(v)
  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
[email protected]
http://joshenglish.livejournal.com
_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig