mardi 14 juin 2016

xml parsing issue encoding error


I have an xml file like this

<?xml version="1.0" encoding="UTF-8"?>
<tw>
    <tweet>
        <yazi>atılacak tweet 1</yazi>
        <resim>resim.png</resim>
    </tweet>
    <tweet>
        <yazi>atılacak tweet 2</yazi>
        <resim>yok</resim>
    </tweet>
</tw>

I'm trying to read it with

import xml.etree.ElementTree as ett

e = ett.parse("tweet.xml").getroot()

But I get this error,

xml.etree.ElementTree.ParseError: encoding specified in XML declaration is incorrect: line 1, column 31

Why? How can I fix this, I searched a lot and xml file looks ok. I don't understand why I can't read the file.


Aucun commentaire:

Enregistrer un commentaire