escaping illegal characters in XML

"Martin v. Löwis" martin at v.loewis.de
Sun Jan 12 12:06:17 CET 2003


Sandy Norton wrote:
> doc.encoding = 'UTF-8'

Why do you think that setting an attribute named "encoding" should have 
any effect on the document?

> <?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.

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





More information about the Python-list mailing list