java在Android中从URL读取XML文件
我尝试了几种从链接打开XML文件的方法,但所有这些方法都没有任何效果。 为了确保解析XML文件是好的,我下载了该文件并将其放在Asset文件夹中,以便解析所有这些内容。 我们可以由此推断从url读取时的错误
URL是http://feeds.bbci.co.uk/sport/0/football/rss.xml?edition=uk
HttpClient httpclient = new DefaultHttpClient();
HttpGet httppost = new HttpGet(url.toString());
HttpResponse response = httpclient.execute(httppost);
InputStream in=response.getEntity().getContent();
或者
HttpURLConnection con=(HttpURLConnection)url.openConnection();
InputStream in=con.getInputStream();
或者
InputStream in =url.openStream();
请帮帮我
我的问题解决了谢谢大家的帮助。当我从Url获取文件时,我应该使用AsyncTask类
# 1 楼答案