ElementTree and DTDs

J. Pablo Fernández pupeno at pupeno.com
Fri May 16 03:32:21 EDT 2008


Or is there another library that would handle DTDs correctly,
performing entity replacements?

Thanks.

On May 16, 12:20 am, J. Pablo Fernández <pup... at pupeno.com> wrote:
> Hello,
>
> Is ElementTree supposed to load DTDs? I have some xmls heavy on
> entities and it fails this way:
>
> Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> filename = "revo/xml/a.xml"
> >>> import xml.etree.ElementTree as ET
> >>> ET.parse(filename)
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/lib/python2.5/xml/etree/ElementTree.py", line 862, in
> parse
>     tree.parse(source, parser)
>   File "/usr/lib/python2.5/xml/etree/ElementTree.py", line 586, in
> parse
>     parser.feed(data)
>   File "/usr/lib/python2.5/xml/etree/ElementTree.py", line 1245, in
> feed
>     self._parser.Parse(data, 0)
>   File "/usr/lib/python2.5/xml/etree/ElementTree.py", line 1201, in
> _default
>     self._parser.ErrorColumnNumber)
> xml.parsers.expat.ExpatError: undefined entity ĵ: line 13,
> column 10>>> import xml.etree.cElementTree as ET
> >>> ET.parse(filename)
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "<string>", line 45, in parse
>   File "<string>", line 32, in parse
> SyntaxError: undefined entity &c_j;: line 46, column 17
>
> Thanks.




More information about the Python-list mailing list