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

Discussion in 'Python' started by Thomas Guetttler, Sep 8, 2003.

  1. 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.

    thomas
     
    Thomas Guetttler, Sep 8, 2003
    #1
    1. Advertising

  2. 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
     
    Thomas Guetttler, Sep 10, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ahmed Moustafa
    Replies:
    10
    Views:
    797
    Tor Iver Wilhelmsen
    Jul 17, 2003
  2. Hugo
    Replies:
    10
    Views:
    1,400
    Matt Humphrey
    Oct 18, 2004
  3. Elaine Cheong
    Replies:
    1
    Views:
    1,056
    Gordon Beaton
    Dec 9, 2006
  4. Mr Major Thorburn

    Exception handling source line number

    Mr Major Thorburn, Mar 12, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    558
    Mr Major Thorburn
    Mar 12, 2008
  5. Mr Major Thorburn

    Exception handling source line number

    Mr Major Thorburn, Mar 12, 2008, in forum: ASP General
    Replies:
    1
    Views:
    249
    Bob Barrows [MVP]
    Mar 12, 2008
Loading...

Share This Page