[XML-SIG] "encoding" argument to xml.dom.minidom.toxml()?

"Martin v. Löwis" martin at v.loewis.de
Mon Jun 23 06:54:25 CEST 2008

> Stefan, I think we are talking past each other.  I know it's there to
> allow encodings other than UTF-8, and I'm familiar with the codecs
> module, and I like the parameter, in general.  The problem is that if
> you ignore the documentation, which seems to know that it's broken,
> and specify an encoding other than UTF-8, the generated XML sometimes
> doesn't conform to that encoding.

Can you give an example? I'm unable to reproduce the behavior you
are seeing; it works just fine for me:

py> import xml.dom.minidom
py> t=d.createTextNode(u"\u20ac")
py> x=d.documentElement.appendChild(t)
py> d.toxml(encoding="iso-8859-15")
'<?xml version="1.0" encoding="iso-8859-15"?><root>\xa4</root>'

AFAICT, this is the correct byte string. Can you give an example where
toxml returns an incorrect byte string?


More information about the XML-SIG mailing list