Hi, Josh English wrote: > 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
Interesting. I just tried and got the same result. I guess I never even tried to do this, given that I knew lxml won't support it anyway... Without debugging into this, it seems that expat raises that exception before ElementTree even gets to handle the unknown entity. I just found this post, but didn't try it: http://mail.python.org/pipermail/python-list/2007-April/607256.html Stefan _______________________________________________ XML-SIG maillist - XML-SIG@python.org http://mail.python.org/mailman/listinfo/xml-sig