I am making an app that will access the ebay api via xml to search for items. I have followed the guide Android developer guide XMLPullParser to use Pull parser, and I am able to parse basic xml fine. BUT for my needs there is not enough info on pullparser, as I am trying to access items in a format not mentioned in neither the link nor the pullparser site.
Product Items are in the Item Array. When trying to run the parser after getting the 1st item returned, the parser moves back to the Item array level instead of looping for each item. This results in the parser running through the whole xml and only returning one item. After trying for a few days, nothing I tried keeps the parser from returning to the Item Array level.
This is the structure of the XML
<FindPopularItemsResponse>
<Timestamp>2013-04-08T18:30:44.139Z</Timestamp>
<Ack>Success</Ack>
<Build>E817_CORE_APILW2_15902151_R1</Build>
<Version>817</Version>
<ItemArray>
<ItemID>330624952975</ItemID><EndTime>2013-05-03T13:31:06.000Z</EndTime>
<ViewItemURLForNaturalSearch></ViewItemURLForNaturalSearch>
<ListingType>FixedPriceItem</ListingType><GalleryURL></GalleryURL>
<PrimaryCategoryID>73522</PrimaryCategoryID><PrimaryCategoryName>
</PrimaryCategoryName><BidCount>706</BidCount><ConvertedCurrentPrice
currencyID="USD">14.95</ConvertedCurrentPrice>
<ListingStatus>Active</ListingStatus><TimeLeft>P24DT19H22S</TimeLeft>
<Title> </Title>
</ItemArray>
</FindPopularItemsResponse>
Thanks
Luke
3
Answers
Without any code this one is actually a tough one to answer.
Your loop structure should probably look like that:
There’s only one item in the xml you provide. Without multiple items in your example its really difficult to answer correctly. But I’ll try for just ItemID. Create a List of ItemID and when you hit text for that node add a new ItemID to the list..
create a list of your object and keep track of the current node
Good Luck with adding items to a list a simple xpp loop
You haven’t quite specified what data you are trying to pull from the xml, so….assuming you want data from each of the tags, here is how i’d do it
hope this helps.