[Python-bugs-list] [ python-Feature Requests-641415 ] xml.dom.minidom.toxml() & encoding

noreply@sourceforge.net noreply@sourceforge.net
Wed, 20 Nov 2002 11:27:59 -0800


Feature Requests item #641415, was opened at 2002-11-20 20:27
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=641415&group_id=5470

Category: XML
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Xavier BASSERY (balthus)
Assigned to: Nobody/Anonymous (nobody)
Summary: xml.dom.minidom.toxml() & encoding

Initial Comment:

Hi,
when I use toxml() from an object resulting from a
parseString() call, the string forgets the encoding
option I've put in it first.

Eg, I write this :

>>> from xml.dom.minidom import parseString
>>> dom = parseString("""<?xml version="1.0"
encoding="ISO-8859-1"?>\
... <TEST>nothing</TEST>""")
>>> print dom.toxml()
<?xml version="1.0" ?>
<TEST>nothing</TEST>

The output string has lost its encoding specification.

So I took a look at the way toxml() was written and
I've seen that it was calling writexml which do this
bad thing (IMHO) :

    def writexml(self, writer, indent="", addindent="",
newl=""):
        writer.write('<?xml version="1.0" ?>\n')

So would it be possible to memorize the options of the
xml in the dom variable ?
Or at list to give in toxml() a parameter  (with '<?xml
version="1.0" ?>\n' as the default value) that will be
used to write the beginning of  the xml string ?

Xavier


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=641415&group_id=5470