Re: How to debug SAX?

From: Chris (nospam_at_nospam.com)
Date: 07/10/04

  • Next message: mike: "IllegalAccessException on public method"
    Date: Sat, 10 Jul 2004 13:40:42 -0500
    
    

    > I have an application that reads XML-data from a network stream. Some-
    > times I get exceptions like this one (catch prints it):
    > SAXParEx: org.xml.sax.SAXParseException: Document root element is missing.
    > Document root element is missing.
    >
    > I have a test application that just connects to the stream and prints
    > the results. There the XML looks OK. Is there a way to see what the
    > parser got presented and what causes the exception?

    Debugging SAX is tricky. You can look at the embedded exception to get a
    clue:

    } catch (SAXException sax) {
      Exception embed = sax.getException();
      embed.printStackTrace();
    }

    The other thing to do is see if you can get *any* XML to parse. If you can,
    then systematically remove elements from your problem XML file until it
    works.

    One problem that I had recently is that a problem file had some UTF-8
    byte-order marks at the beginning of the file, before the first tag. This
    cause a "root element missing" error.


  • Next message: mike: "IllegalAccessException on public method"

    Relevant Pages

    • XMLFilter exception
      ... throws the following exception (on certain input documents, not all and, ... alas, I were not able to locate the problem): ... root element of: HTML Nested exception: The node ... to this Document as it already has a root element of: ...
      (comp.lang.java.programmer)
    • how to resolve System.Configuration.ConfigurationErrorsException?
      ... "InitializeComponent" routine to throw an exception "Root element is ... when I start my app. ...
      (microsoft.public.dotnet.languages.csharp)
    • How do I restore a corrupted user.config file?
      ... "InitializeComponent" routine to throw the exception "Root element is ... when I start my app. ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: multiple same section in app.config
      ... Well, it will, but you have to have one root element that is not ... <myCustomGroup> ... I got the same exception = "Sections must only appear once per config ...
      (microsoft.public.dotnet.languages.csharp)
    • RE: Root element is missing
      ... How to reload the project. ... The csroj file is in xml ... format and the error indicates the xml is invalid (root node is missing or ...
      (microsoft.public.dotnet.framework)