2010-09-14 31 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拉式解析器解析它。