elementtree.SimpleXMLWriter and xmlcharrefreplace

P

peterbe

I'll try to explain my problem with code.
The problem is the output

msg = u"Södertälje & Borås" # latin1 unicode string with a &

from elementtree.SimpleXMLWriter import XMLWriter
from cStringIO import StringIO
out = StringIO()
w = XMLWriter(out)
body = w.start("body")
w.element("text", msg)
w.close(body)
return out.getvalue()

Here's the output I get:
<body><text>Södertälje &amp; Borås</text></body>
Here's what I would want and expect:
<body><text>Södertälje &amp; Borås</text></body>

Notice that & is converted to &amp; when it should be &amp; or &38;
only.
 
P

peterbe

My current version of SimpeXMLWriter is:
$Id: SimpleXMLWriter.py 1862 2004-06-18 07:31:02Z Fredrik $
I'm testing this on in python2.3.5 and python2.4.3.
 

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

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top