我想获得字符串一页 xml 响应,但我的脚本总是关闭,有人知道这有什么问题吗?在清单中我采取:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
代码:
String URL = "http://sample.com/test.xml";
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(URL);
try {
response = httpclient.execute(httppost);
} catch (ClientProtocolException e1) {
// TODO Auto-generated catch block
} catch (IOException e1) {
// TODO Auto-generated catch block
}
HttpEntity r_entity = response.getEntity();
try {
xmlString = EntityUtils.toString(r_entity);
String s = "2";
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}