0
我正在使用此方法从远程服务器获取xml文件,我使用另一个解析器类来解析它,并且它已成功解析。但是,当我使用Log.d("get xml", xml)
来检查xml文件的内容时,它只在logCat中显示<?xml version="1.0" standalone="no"?>
。为什么?为什么我只需要获取<?xml version =“1.0”standalone =“no”?>何时请求一个xml文件? Android
public String getXmlFromUrl(String url) {
String xml = null;
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
if(httpPost != null){
Log.d("httpPost", "httpPost not null");
}
HttpResponse httpResponse = httpClient.execute(httpPost);
if(httpResponse != null){
Log.d("httpResponse", "httpResponse not null");
}
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
Log.d("get xml", xml);
if(xml!=null){
Log.d("get http client", "get http client not null");
}
return xml;
}