我在从XML
加载URL
文件时遇到问题。这是我的代码。
onCreate()
:
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser parser = factory.newPullParser();
InputStreamReader data = new InputStreamReader(getUrlData("http://localhost/Videos.xml"));
parser.setInput(data);
getUrlData()
:
public InputStream getUrlData(String url) throws URISyntaxException, ClientProtocolException, IOException {
DefaultHttpClient client = new DefaultHttpClient();
HttpGet method = new HttpGet(new URI(url));
HttpResponse res = client.execute(method);
return res.getEntity().getContent();
}
我的错误在哪里?