This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "help "Error parsing XML document: null"" Watch "help "Error parsing XML document: null"" New topic
Author

help "Error parsing XML document: null"

Eric lau
Greenhorn

Joined: Jan 21, 2002
Posts: 27
I have some code like this:
XMLReader parser = null;
String parserClass = System.getProperty("org.xml.sax.driver",
"org.apache.xerces.parsers.SAXParser");
try {
parser = XMLReaderFactory.createXMLReader(parserClass);
// Set entity resolver, if needed
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
// Set error handler, if needed
if (errorHandler != null) {
parser.setErrorHandler(errorHandler);
}
// Register content handler
parser.setContentHandler(trade_Code);
} catch (SAXException e) {
throw new IOException("Could not load XML parser: " +
e.getMessage());
}
InputSource inputSource = new InputSource(reader);
try {
parser.setFeature("http://xml.org/sax/features/validation", new Boolean(validate).booleanValue());
parser.parse(inputSource);
} catch (SAXException e) {
throw new IOException("Error parsing XML document: " +
e.getMessage());
}
sometime it is work,sometime it throw Exception
"Error parsing XML document: null", anyone know what it is wrong?
help!


I come from China
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
can u give us some insight into the trace?
where is it throwing the null error.
When u say it works , you mean it behaves differently @ different times for the same input xml file?
Eric lau
Greenhorn

Joined: Jan 21, 2002
Posts: 27
Thanks
When it works , the parser has the same input xml file!
The message is threw at:
try {
parser.setFeature("http://xml.org/sax/features/validation", new Boolean(validate).booleanValue());
parser.parse(inputSource);
} catch (SAXException e) {
throw new IOException("Error parsing XML document: " +
e.getMessage());
}
So ,null is return by e.getMessage().
Do you know what is wrong?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help "Error parsing XML document: null"
 
Similar Threads
Gettin' crazy cuz of SAX
Problem with using InputSource in SAXParser
Getting Node Value using SAX
Parsing XML elements
XML in applet is not working......:-(