[XML-SIG] "encoding" argument to xml.dom.minidom.toxml()?
janssen at parc.com
Tue Jun 10 21:13:35 CEST 2008
I've been using the minidom to produce little properly-formatted XML
documents, by building a DOM tree, then calling "toxml" to generate
the actual XML. But I tripped over the optional "encoding" argument
to that function.
I figured that the only point of having an encoding argument would be
to allow the user to control the output character set encoding, but it
turns out that specifying an encoding of, say, "ASCII", doesn't do
that. It just raises encoding exceptions when you attempt to encode a
non-ASCII character. What's the point of having an encoding argument
when it always has to be "UTF-8"?
Especially since it seems that this could be made useful by changing
one line of code. In xml/dom/minidom.py, in the class Node, in the
method "toprettyxml", change the line
writer = codecs.lookup(encoding)(writer)
writer = codecs.lookup(encoding)(writer, "xmlcharrefreplace")
What am I missing here?
More information about the XML-SIG