Wednesday, August 30, 2006

org.xml.sax.SAXParseException: Premature end of file

I got this error bse the http response was empty

java.net.MalformedURLException: no protocol

These days i am working with a project with http response processing. I faced with follwoing exeption when parsing the http response via DOMParser
java.net.MalformedURLException: no protocol

my code was:
String xml = (String) parseEnv.get(RESPONSE_BODY);

DOMParser parser = new DOMParser();

parser.reset();
try {
parser.parse(new InputSource(xml);
} catch (Exception e) {
throw new ParseException(e);
}
The error was InputSource expects an SystemId. This can be accomplished as
parser.parse(new InputSource(new StringReader(xml)));