开发者

how data can be parsing in xml parsing and data show in listview in android

I have a doubt in xml parsing. How to do XML parsing in this type of example:

<companies>
  <company name="ramki" symbol="ram"/>
  <company name="addidas" symbol="ads"/>
  <company name="samsang"开发者_运维问答 symbol="sam"/>
  .................

and also tell me how to show the in ListView (name and symbol also)


Here's an excellent tutorial on XML Parsing and for the second question this should be helpful.

EDIT: After Posting your sample, i see that you'll needing the Attributes Field in the startElement

public void startElement(String namespaceURI, String localName,
                        String qName, Attributes atts) throws SAXException

use atts.getValue("name") to get the name...do the same for symbol.


Two parts :

  • for XML parsing, it's the same thing as in Java. You can see this question about XML parsing. As said in the link MGS provided, StaX is not implemented in Android, but can be easily replaced by the XMLPullParser.
  • As for displaying your data in a ListView, you'll juste have to use an ArrayAdapter. For more help about lists, see the associated resource in Android Help.


go through this link and try the same by using Working with DOM parsing http://www.ibm.com/developerworks/opensource/library/x-android/, to display parsed single content in Listview,simply use array adapter to set in Listview,if you want to show multiple items in list row go ahead for custom adapter.

I hope it may help you much....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜