minidom utf-8 encoding

"Martin v. Löwis" martin at v.loewis.de
Thu Jan 4 03:33:17 EST 2007


fscked schrieb:
> Hi guys/gals.
> 
> I am trying to write and xml file from data parsed from a csv.
> 
> I can get everything to work except that I cannot get minidom to do -->
> ö which needless to say is driving me nuts.
> 
> Any suggestions?

Works fine for me:

py> d = minidom.Document()
py> r = d.createElement("root")
py> r.appendChild(d.createTextNode(u"\xf6"))
<DOM Text node "\xf6">
py> d.appendChild(r)
<DOM Element: root at -0x482ab614>
py> d.toxml()
u'<?xml version="1.0" ?>\n<root>\xf6</root>'
py> print d.toxml()
<?xml version="1.0" ?>
<root>ö</root>

Regards,
Martin



More information about the Python-list mailing list