小编Emr*_*lil的帖子

Android中的HttpResponse

我有一个问题,我想解析网络上的XML文件.现在我的HttpResponce得到太多的时间也读取了XML文件,所以我得到了我的GUI的错误"成为运行时错误".

try {

        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost("http://chukk.nuzoka.com/name.xml");

        HttpResponse httpResponse = httpClient.execute(httpPost);

        HttpEntity httpEntity = httpResponse.getEntity();
        line = EntityUtils.toString(httpEntity);


    } catch (UnsupportedEncodingException e) {
        line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
    } catch (MalformedURLException e) {
        line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
    } catch (IOException e) {
        line = "<results status=\"error\"><msg>Can't connect to server</msg></results>";
    }
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏:)

android httpresponse

5
推荐指数
1
解决办法
3295
查看次数

标签 统计

android ×1

httpresponse ×1