【问题标题】:Android REST XML result to ListviewAndroid REST XML 结果到 Listview
【发布时间】:2010-08-27 11:40:28
【问题描述】:

我有一个 REST Web 服务,它返回如下 xml 结果:

- <MyCategories xmlns="http://schemas.datacontract.org/2004/07/ceva" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
- <Category>
  <CategoryName>First category</CategoryName> 
  <Id>1</Id> 
  </Category>
- <Category>
  <CategoryName>Second category</CategoryName> 
  <Id>2</Id> 
  </Category>
- <Category>
  <CategoryName>Third category</CategoryName> 
  <Id>3</Id> 
  </Category>
  </MyCategories>

我这样访问网络服务:

     HttpClient httpclient = new DefaultHttpClient();  
     HttpGet request = new HttpGet(WebServiceURL);  
     request.addHeader("deviceId", deviceId);  
     BasicResponseHandler handler = new BasicResponseHandler();  

     result = httpclient.execute(request, handler);

结果我从 Web 服务获得了 xml 响应。我希望能够使用此结果并将其显示在列表视图中。

我怎样才能做到这一点? 谢谢。

【问题讨论】:

    标签: android rest sax xml-parsing


    【解决方案1】:

    您将要创建一个自定义 SAXParser 类。

    这是一个不错的小tutorial

    还有docs(不过他们解释得不是很好)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-25
      相关资源
      最近更新 更多