how to get elements by a tag name in Saxparser in android
in my app when i click a button it gets an xml file from an url and it moves to a new actvity B. In activity B i have a list view, where the tag "name" are been listed out.
My xml file is as follows
<search>
<data>
<userid>1</userid>
<name>Jean</name>
<address>dbvsvksn</address>
<dob>Mar 3</dob>
<country>us</country>
</data>
<data>
<userid>2</userid>
<name>Anne</name>
<address>dbvsvksn ,</address>
<dob>Jun 2<dob>
<country>us</country>
</data>
<data>
<userid>3</userid>
<name>J</name>
<address>dbvsvksn ,</a开发者_如何学编程ddress>
<dob>Dec 6<dob>
<country>us</country>
</data>
</search>
when i click on any item on the list view it opens a new Activity C. Here in a text view i want to display the name i have clicked in the previous activity and i have to show the address, dob, country of the name that been clicked.
Now i have listed out the name's using Sax parser in activity B and using intent i have printed the name in activity C but how to get the other related tag's.
please help me...
I think you should make a class Users
containing fields like id, name, address, dob etc with their setter getter
method. and when you receive XML, parse it using DOM
, and save their values in array of Users
Object. By this you can access every field by just calling getter methods. You can pass that objects to other activity, or access them anywhere if they are static.
精彩评论