[XML-SIG] Newbie : Identifying characters that will choke XML parser

Ian Sparks Ian.Sparks@etrials.com
Tue, 6 May 2003 12:45:33 -0400


Thank you James & John your solutions allow me to filter out what should =
be marked as "bad" characters.

However, I'm having real problems with character conversions. I'm =
building an xml document using minidom and setAttributeNS()

I want to be able to do something like :

from xml.dom.minidom import parseString

doc1 =3D parseString('<test/>')
docNode =3D doc1.childNodes[0]
docNode.setAttributeNS(None,'a',chr(180))
source =3D doc1.toxml('iso-8859-1')

and have source contain :

<?xml version=3D"1.0" encoding=3D"iso-8859-1" ?>=20
<test a=3D"&#180;"/>

without getting UnicodeErrors from codecs.py on toxml() and without =
ending up with :

<?xml version=3D"1.0" encoding=3D"iso-8859-1" ?>=20
<test a=3D"&amp;#180;"/>

Either this is really hard or, more likely, I'm really ignorant.