python 2.5 cElementTree entity troubles

D

Diez B. Roggisch

Hi,

this snippet, adapted from

http://svn.effbot.org/public/tags/celementtree-1.0-20050126/selftest.py

fails miserably with an unknown entity exception:

from xml.etree.cElementTree import *

ENTITY_XML = """
<document>&entity;</document>
"""

parser = XMLTreeBuilder()
parser.entity["entity"] = "text"
print parser.entity

parser.feed(ENTITY_XML)
root = parser.close()


Any suggestions on how to teach the built-in ET-parser entities?

Python version is Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) on OSX.

Regards,

Diez
 
D

Diez B. Roggisch

Stefan said:
Hmmm, I never needed this, but the test doesn't work for me either (with ET
1.3, Python 2.5.1). ET's parser uses the generic expat callback for entities,
but it doesn't seem to get called for entities on my side... Looks like
something's broken there.

I tried to go with explicit cElementTree and elementtree-installations -
same problem....

Could this be a bug in the underlying python-shipped expat parser?

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,253
Latest member
BlytheFant

Latest Threads

Top