encoding ascii data for xml
Dillon Collins
dillonco at comcast.net
Fri Oct 3 20:25:43 EDT 2008
On Friday 03 October 2008, harrelson wrote:
> import xml.dom.minidom
> print chr(3).encode('utf-8')
> dom = xml.dom.minidom.parseString( "<test>%s</test>" %
> chr(3).encode('utf-8') )
>
> chr(3) is the ascii character for "end of line". [...] My
> question is why doesn't encode() blow up?
You just answered your question. 0x03 may not be a printing character, but it
is a valid character in the ascii character set and therefore is not a
problem. For xml, however, it is an illegal character so that's why the
parser is throwing an error.
More information about the Python-list
mailing list