minidom and unicode errors

Fredrik Lundh fredrik at
Tue Mar 7 07:39:52 CET 2006

Abhimanyu Seth wrote:

> > I have the following line in my xml file:
> > <target>Exception beim Löschen des Audit-Moduls aufgetreten. Exception
> Stack
> > lautet: %1.</target>
> > ExpatError: not well-formed (invalid token): line 8, column 27

> I've specified utf-8 in the xml header
> <?xml version="1.0" encoding="utf-8"?>

are you sure you're using utf-8 in the XML file?  the ö you pasted into
your mail is an iso-8859-1 code, not an utf-8 code.

> Anyway,
> >> f = ("c:/test.txt", "r", "latin-1")
> >> dom = minidom.parseString (codecs.encode (, "utf-8"))
> works.

which means that you've labelled the file as utf-8, but that it actually
contains iso-8859-1.  fixing the file should fix this.


More information about the Python-list mailing list