Parsing error, line 1, uri null

Hi ,

I have a program which is using DocumentBuilder to parse an xml.The program is working fine when a parse a simple xml file which is stored in my local system.I would like to know is there any way to parse the xml which i am getting from response.Here is the program to get xml response

URL url = new URL(strUrl);

URLConnection connection = url.openConnection();

connection.setDoOutput(true);

PrintWriter out = new PrintWriter(connection.getOutputStream());

out.println("Msg=" + strHtml);

out.close();

BufferedReader in = new BufferedReader(

new InputStreamReader(

connection.getInputStream()));

String inputLine;

String xmlReturned = "";

while ((inputLine = in.readLine()) != null){

System.out.println(inputLine);

xmlReturned = xmlReturned + inputLine;

}

This is the parser code i am using

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

Document doc = docBuilder.parse(connection.getInputStream());

But i am getting an error Parsing error, line 1, uri null if i run this code

[1216 byte] By [naduparambila] at [2007-9-24]
# 1
Why go to all of the trouble of making the connection and getting the input stream yourself? There's also an overloaded parse() method that takes the URL string as a parameter and does all of that for you.
DrClapa at 2007-7-16 > top of java,Enterprise & Remote Computing,Enterprise Technologies...