Unicode strings -> xml.dom.minidom Text elements?

Patrick Surry Patrick.Surry at quadstone.com
Mon Oct 21 12:29:37 EDT 2002


I've got a unicode string like:

a = u'ABC\u03A3DEF'

and am stuffing it into an xml.dom.minidom Text() element.  But when I
serialize the document with doc.writexml(), it turns into:

<text>ABC?DEF</text>

rather than:

<text>ABC&#x3A3;DEF</text>

as I was hoping.

This seems to be because writexml() effectively does 

writer.write('%s' % a)

making the unicode character turn into a '?'

Am I doing something dumb and/or is there a workaround I could use other than
writing my own XML unicode character escaper...

Cheers,
Patrick


-- 
_________________________________________________________________________
Patrick Surry, PhD  Tel 617 753 7393 Fax 617 457 5299   www.quadstone.com
- With the breadth of our knowledge grows the boundary of our ignorance -




More information about the Python-list mailing list