Android REST XML result to Listview
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>
I acces the web service like this:
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(WebServiceURL);
request.addHeader("deviceId", deviceId);
BasicR开发者_开发问答esponseHandler handler = new BasicResponseHandler();
result = httpclient.execute(request, handler);
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.
You're going to want to create a custom SAXParser class.
Here's a nice little tutorial
And the docs (they don't explain this that well though)
精彩评论