ExpatError attributes
Fredrik Lundh
fredrik at pythonware.com
Fri Nov 4 09:52:48 EST 2005
Daniel Nogradi wrote:
> According to the documentation the xml.parsers.expat module provides
> the exception ExpatError and this exception has 3 attributes, lineno, offset
> and code. I would like to use lineno, but can't.
> try:
> minidom.parse("my.xml")
> except ExpatError:
> print 'The file my.xml is not well-formed.'
> print 'And the problem is here: ', ExpatError.lineno
you're supposed to look at the exception instance, not the class
that defines it:
try:
minidom.parse("my.xml")
except ExpatError, v:
print 'The file my.xml is not well-formed.'
print 'And the problem is here: ', v.lineno
more here:
http://docs.python.org/tut/node10.html
</F>
More information about the Python-list
mailing list