minidom utf-8 encoding

fscked fsckedagain at gmail.com
Thu Jan 4 11:24:49 EST 2007


Martin v. Löwis wrote:
> 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

Well, let me clarify. If I just print it to the screen/console it works
fine, but when I do:

out.write( doc.toprettyxml())

it just removes the character that would be the "ö".

I can post the code if anyone wants to see it, but it is fairly
straightforward.




More information about the Python-list mailing list