SAXParseException when URL is non-existent
I am trying to parse an xml using DocumentBuilder's parse method which takes URI as an argument. For this I create a String object representing the URI and then call the parse method passing the String object as the argument.

The parse method call works fine, returns a new DOM object. However, when I try to print the returned DOM object, it says: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. The code snippet for parsing the xml is as shown below:

    String sURL="http://host:port/myapp/myfile.xml";   
    DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();      
    doc = dBuilder.parse(sURL);


However, when the URL is a non-existent one, the parse method still returns 

> org.xml.sax.SAXParseException: The markup in the document following
> the root element must be well-formed.

Any thoughts on how I could identify a non-existent URL during a parse method call?

Thanks.
SAXParseException when URL is non-existent
===

I am trying to parse an xml using DocumentBuilder's parse method which takes URI as an argument. For this I create a String object representing the URI and then call the parse method passing the String object as the argument.

The parse method call works fine, returns a new DOM object. However, when I try to print the returned DOM object, it says: org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. The code snippet for parsing the xml is as shown below:

    String sURL="http://host:port/myapp/myfile.xml";   
    DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();      
    doc = dBuilder.parse(sURL);


However, when the URL is a non-existent one, the parse method still returns 

> org.xml.sax.SAXParseException: The markup in the document following
> the root element must be well-formed.

Any thoughts on how I could identify a non-existent URL during a parse method call?

Thanks.