[XML-SIG] "encoding" argument to xml.dom.minidom.toxml()?
Bill Janssen
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)[3](writer)
to
writer = codecs.lookup(encoding)[3](writer, "xmlcharrefreplace")
What am I missing here?
Bill
More information about the XML-SIG
mailing list