如何从这个 URL获取 XML到String
Android 上?我试图用教程来做,但没有成功。这是我的代码:
public String getXmlFromUrl(String url) {
String text = "";
try {
HttpGet get = new HttpGet(url);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(get);
InputStream inputStream = response.getEntity().getContent();
String line = "";
BufferedReader rd = new BufferedReader(new InputStreamReader(inputStream));
while ((line = rd.readLine()) != null) {
text += line;
}
} catch (Exception e) {
e.printStackTrace();
}
return text;
}