escaping illegal characters in XML

Sandy Norton sandskyfly at hotmail.com
Sun Jan 12 12:00:31 EST 2003


Martin v. Löwis wrote in message

> > doc.encoding = 'UTF-8'
> 
> Why do you think that setting an attribute named "encoding" should have 
> any effect on the document?

two reasons:

1. the lack of a setEncoding attribute to the minidom.Document class
led me the not so unobvious supposition that setting the encoding
attribute could have an impact on the resulting xml document's
encoding.

2. sparse documentation for the xml.dom.minidom module 


> > <?xml version="1.0" ?>
> > <section>
> > 	<item harvested="blah blah"/>
> > </section>
> 
> Strictly speaking, this document *is* encoded in UTF-8: UTF-8 is the 
> default if no encoding= attribute is given.

Thanks. I missed that little detail.

> However, minidom normally won't support output in different encodings. 
> In PyXML (and Python 2.3), the .tostring method of the document supports 
> an optional encoding argument.
> 
> Regards,
> Martin

Cheers,

Sandy




More information about the Python-list mailing list