ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button
  XML Document Validation with an XML Schema
Subject:   org.xml.sax.SAXParseException: Document root element is missing
Date:   2008-09-07 22:56:30
From:   Iruu
I have a java file in which i parse a xml file

URL url = new URL(address);
con = (HttpURLConnection)(url.openConnection());
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(in);

Error occurs in the last line only for some xml files.
the xml files are well formed and is downloaded from google so no error can be in that ,
what may the reason for the error.
the error is as follows
org.xml.sax.SAXParseException: Document root element is missing
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3364)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:668)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:185)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
at com.df.semtools.adwords.GetAdwordsStats.getKeywords(GetAdwordsStats.java:278)
Thanks for ur help in advance