2010-09-14 54 views
1

我想使用SAX PArser解析我的应用程序中的XML响应,我不知道该怎么做,所以任何人都可以让我走向正确的道路。解析Android应用程序中的XML响应

有一点编码或链接的例子是可以的。 谢谢, 大卫

回答

1
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(); 
    } 

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