Ask for an example code for parsing xml and get attributes by using GData API
When i use GData API in my app for parsing xml,how could i get attributes and it's value? Wanted a piece of example code.Thanks a lot. xml:
<playurls><url islive="0" type="3" bit_stream="1">http://vods.netitv.com//dy2/2010/02/08/cf584b76-3579-4b75-a0c8-f7a473d79f8c.mp4
</url><url islive="0" type="3" bit_stream="2">http://vods.netitv.com//dy/2010/02/08/965bbc65-8ec0-4c50-98ae-c69a831926cc.mp4
</url><url islive="0" type="2" bit_stream="1">http://vods.netitv.com//dy2/2010/02/08/cf584b76-3579-4b75-a0c8-f7a473d79f8c.mp4
</url><url islive="0" type="2" bit_stream="2">http://vods.netitv.com//d开发者_JS百科y/2010/02/08/965bbc65-8ec0-4c50-98ae-c69a831926cc.mp4
</url></playurls>
NSInteger type=[[(GDataXMLNode *)[[urls objectAtIndex:i] attributeForName:@"type"] stringValue] intValue];
NSInteger bit_stream=[[(GDataXMLNode *)[[urls objectAtIndex:i]attributeForName:@"bit_stream"] stringValue] intValue];
Google have provided quite a lot of sample code that shows how to use their API. Depending of which protocol you use, you should be able to get the samples from the API Directory.
精彩评论