I want to Parse an XML which has data differentiated on the basis of id (can say in tabular form) and to show it in Textviews (one id at a time) Can you help me in this regard?? Preferably in XML PullParser as it is recommended by android
I want XML values to put in Textviews one at a time based on their IDs
<myXmlStarts>
<Id>1</id>
<EnglishData>"this is 1st English line"</EnglishData>
<UrduData>"this is 1st Urdu line"</UrduData>
</myXmlStarts>
<myXmlStarts>
<Id>2</id>
<EnglishData>"this is 2nd English line"</EnglishData>
<UrduData>"this is 2nd Urdu line"</UrduData>
</myXmlStarts>
You can do something like ,
Model.class
Output :
What i did was,
ArraList
with paramater asModel
.myXmlStarts
as START_TAG, it just initialize the model class. (model = new Model();)Id
,EnglishData
etc..myXmlStarts
, it just adds that toArrayList
(listData.add(model);) and the same thing happens until the end of document.Now, you have all the data in
ArrayList
. Just add these values totextView
. I just finished your half job. Rest, you have to try. Good luck.NOTE :
You have a error in your xml tags.
Change
to