By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

elementtree.SimpleXMLWriter and xmlcharrefreplace

P: n/a
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.

Jan 5 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

pe*****@gmail.com wrote:
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.
Jan 5 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.