REALLY simple xml reader

Ricardo Aráoz ricaraoz at gmail.com
Thu Jan 31 18:55:54 EST 2008


Diez B. Roggisch wrote:
> Ricardo Aráoz schrieb:
>> Diez B. Roggisch wrote:
>>> Ricardo Aráoz schrieb:
>>>> Thanks Ivan, it seems a elegant API, and easy to use.
>>>> I tried to play a little with it but unfortunately could not get it off
>>>> the ground. I kept getting
>>>>>>> root = et.fromstring(doc)
>>>> Traceback (most recent call last):
>>>>   File "<input>", line 1, in <module>
>>>>   File "E:\Python25\lib\xml\etree\ElementTree.py", line 963, in XML
>>>>     parser.feed(text)
>>>>   File "E:\Python25\lib\xml\etree\ElementTree.py", line 1245, in feed
>>>>     self._parser.Parse(data, 0)
>>>> ExpatError: XML or text declaration not at start of entity: line 2, column 0
>>> That's a problem in your XML not being XML. Has nothing to do with 
>>> element-tree - as one sees from the error-message "ExpatError". If you 
>>> show it to us, we might see why.
>>>
>> Sure,
>>
>> doc = """
>> <?xml version="1.0"?>
> 
> It's not allowed to have a newline before the <?xml ...>
> 
> Put it on the line above, and things will work.
> 
> Diez

Worked ok. Thanks a lot to you all, I'm not using it right now but I've
had a taste and now know where to look and how to start.
Cheers





More information about the Python-list mailing list