[jdom-interest] Exceptions thrown because of comments before root element

Dave Bartmess dingodave at edingo.net
Sun Jul 6 16:11:34 PDT 2003


I'm not sure if this is valid XML or not, but I'm trying to write an RSS
Feed reader/writer/parser, based on jdom. 

The URL of the file I'm trying to parse is
http://sourceforge.net/export/rss2_projnews.php?group_id\=63234

This is a normal standard for several sites that I've seen putting out
RSS feeds, to put a comment between the xml header element
(designation?) and the root element.

Is this valid? If it is, why does SAXBuilder croak on it?

The code I'm using to read the inputstream and the errors I'm getting
are below.

*******************************************
   protected void read(URL url) throws ChannelParseException {
      try {
         org.jdom.input.SAXBuilder builder = new  SAXBuilder(true);
         setChannel(builder.build(url));
      }
      catch (java.net.MalformedURLException exc) {
         throw new ChannelParseException(exc) ;
      }
      catch (org.jdom.JDOMException exc) {
         throw new ChannelParseException(exc) ;
      }
      catch (java.io.IOException exc) {
         throw new ChannelParseException(exc) ;
      }
   }
   
**************************************
org.edingo.JParsse.core.ChannelParseException:
org.jdom.input.JDOMParseException: Error on line 1 of document
http://sourceforge.net/export/rss2_projnews.php?group_id\=63234:
Document root element is missing.
    at org.edingo.JParsse.core.Channel.read(Channel.java:131)
    at org.edingo.JParsse.core.Channel.<init>(Channel.java:105)
    at org.edingo.JParsse.core.Channel.main(Channel.java:654)
Caused by: org.jdom.input.JDOMParseException: Error on line 1 of
document
http://sourceforge.net/export/rss2_projnews.php?group_id\=63234:
Document root element is missing.
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:377)
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:724)
    at org.edingo.JParsse.core.Channel.read(Channel.java:125)
    ... 2 more
Caused by: org.xml.sax.SAXParseException: Document root element is
missing.
    at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3182)
    at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3170)
    at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:501)
    at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
    at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:370)
    ... 4 more

-- 
David A. Bartmess
Software Configuration Manager / Sr. Software Developer
eDingo Enterprises
http://edingo.net




More information about the jdom-interest mailing list