为什么要解析 HttpResponse ?它不存在...为字符串解析存在也许你想做:
Document document = strResp.parse();
如果 strResp 是一个字符串,这将起作用。但也许这不是你想要的。
我这样做(我在网上找到了它,它对我来说非常有效):
public String getXmlFromUrlHttp(String url)
{
String xml = null;
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpPost = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
xml = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return xml;
}
然后你解析函数的结果;)