error when parsing xml

Fredrik Lundh fredrik at pythonware.com
Mon Sep 5 09:01:45 EDT 2005


Odd-R. wrote:

> This is retrieved through a webservice and stored in a variable test
>
> <?xml version='1.0' encoding='utf-8'?>
> <!-- DTD for xmltest-->
> <!DOCTYPE testtest [ <!ELEMENT testtest ( test*)>
> <!ELEMENT test (#PCDATA)>]>
> <testtest><test>æøå</test></testtest>
>
> printing this out yields no problems, so the trouble seems to be when executing
< the following:
>
> doc = minidom.parseString(test)

unless we have a cut-and-paste problem here, that looks like invalid XML;
the header says UTF-8, but the test element contains ISO-8859-1 text.

try changing "utf-8" to "iso-8859-1" to see if that helps.

and you really need to fix the originating system, to make sure that the en-
coding header matches the encoding used for the content.

</F> 






More information about the Python-list mailing list