解析在Android应用程序的XML响应 [英] Parsing the XML Response in an Android Application

查看:74
本文介绍了解析在Android应用程序的XML响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想解析使用SAX解析器我的应用程序的XML响应,我不知道该怎么做,所以任何人都可以请giude我在正确的道路。

用少许编码或一个链接的一个例子将是确定。 谢谢, 大卫

解决方案

 尝试{
        HttpClient的客户端=新DefaultHttpClient();
        串的getURL =&其中; URL取代;
        HTTPGET GET =新HTTPGET(的getURL);
        HTT presponse responseGet = client.execute(获得);
         mResEntityGet = responseGet.getEntity();
        如果(mResEntityGet!= NULL){
            //做一些与响应
            内容= EntityUtils.toString(mResEntityGet);
        }
    }赶上(例外五){
        e.printStackTrace();
    }
 

内容将是XML格式的字符串,使用XML拉式解析器解析它。

I want to Parse the XML Response in my Application using a SAX PArser, I don't know how to do that, So Can anybody please giude me to the right path.

An example with a little coding or a link will be OK. Thanks, david

解决方案

try {
        HttpClient client = new DefaultHttpClient();
        String getURL = <URL>;
        HttpGet get = new HttpGet(getURL);
        HttpResponse responseGet = client.execute(get);
         mResEntityGet = responseGet.getEntity();
        if (mResEntityGet != null) {
            //do something with the response
            content = EntityUtils.toString(mResEntityGet);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

"content" will be the string of XML format, parse it using XML pull parser.

这篇关于解析在Android应用程序的XML响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆