本文介绍了Android的REST XML结果的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个返回XML结果这样的REST Web服务:

I have a REST web service that returns an xml result like this:

- <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>

我存取权限这样的Web服务:

I acces the web service like this:

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

     result = httpclient.execute(request, handler);

在结果我从Web服务的XML响应。我希望能够使用此结果,并在列表视图中显示它。

In result I get the xml response from the web service. I want to be able to use this result and display it in a listview.

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

How can I achieve this ?Thank you.

推荐答案

您会想创建一个自定义SAXParser类。

You're going to want to create a custom SAXParser class.

下面是一个可爱的小教程

文档(他们没有解释这那么好,虽然)

And the docs (they don't explain this that well though)

这篇关于Android的REST XML结果的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:03