无法从URL加载xml文件

时间:2015-01-26 20:14:59

标签: java android xml download xmlpullparser

我在从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();
}

我的错误在哪里?

0 个答案:

没有答案
相关问题