ElementTree and DTDs

  • Thread starter J. Pablo Fernández
  • Start date

J

J. Pablo Fernández

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.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 &jcirc;: line 13,
column 10Traceback (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.
 
Ad

Advertisements

J

J. Pablo Fernández

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

Thanks.

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"
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 &jcirc;: line 13,
column 10>>> import xml.etree.cElementTree as ET
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.
 
Ad

Advertisements


Top