xml.sax: Raising Exception with line number of xml source

Thomas Guetttler guettli at thomas-guettler.de
Wed Sep 10 09:54:36 EDT 2003


Am Mon, 08 Sep 2003 17:08:56 +0200 schrieb Thomas Guetttler:

> Hi!
> 
> How can I raise an exception while parsing with sax,
> which contains the current line in the xml-file?
> 
> I want to create an message like this:
>  test.xml: Line: 100, Col: 20: <foo> not allowed in <bar>
> 
> I have the filename in my content handler. I just need
> the line und column number.


Found it myself:

in e.g. startElement() of MyContentHandler:
  self._locator.getLineNumber()

 thomas





More information about the Python-list mailing list