I receive an XML from HTTP server as a String:
HttpResponse httpResponse = httpClient.execute (httpPost);
return EntityUtils.toString (httpResponse.getEntity ());
This String somehow appears to have two values, because when I try to log it’s length I get two lines in Logcat:
Log.d ("XML", xml.length () + "");
17:30:22.313 19712 DEBUG XML 161
17:30:22.313 19712 DEBUG XML 0
And when I try to parse this XML with DOM parser, I get org.xml.sax.SAXParseException: Unexpected end of document.
I read about something similar here. I know it’s not me who’s doing something wrong when I get two Logcat lines with a single line of code. What could be the problem?
Requesting XML in the same method as parsing it as opposed to passing XML String via method arguments fixed the issue. I used exactly the same code, just moved it to another method. It seems to be some weird Android or NetBeans bug.