0

I'm trying to us NSXML to parse a user's channel from youtube. Parsing works ok, but I can't seem to figure out how to get the link from any specific movie as their are 5 exact the same nodes as following:

<link rel="alternate" type="text/html" href="http://www.youtube.com/watch?v=vLleTDikufefbk&amp;feature=youtube_gdata" /> 
<link rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/vLleTDikededubk/responses" /> 
<link rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/vLlededTDikubk/related" /> 
<link rel="http://gdata.youtube.com/schemas/2007#mobile" type="text/html" href="http://m.youtube.com/details?v=vLldedeeTDikubk" /> 
<link rel="self" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/users/node/uploads/vLlgrgreTDikubk" /> 

I've figured out how to get the attribute href from the node link. But since their are 5 different links I don't know how to only select the first one. Anyone got an idea?

Thnx you guys!!!

Jos
  • 2,421
  • 5
  • 26
  • 30
  • Found the solution already. I'll check if the link node has an attribute with alternate in it. If it does it has the right link node. Here is the code: NSMutableArray *link; if ([elementName isEqualToString:@"link"]) if (!link) link = [[NSMutableArray alloc] init]; NSString *alternate = [attributeDict objectForKey:@"rel"]; if([alternate isEqualToString:@"alternate"]){ NSString *href = [attributeDict objectForKey:@"href"]; alternate = NULL; } – Jos Jun 02 '11 at 14:29
  • You CAN answer your own question. – gcamp Jun 02 '11 at 14:37
  • After 8 hours if you have less then 100 points.... – Jos Jun 02 '11 at 15:28

1 Answers1

0

Found the solution already. I'll check if the link node has an attribute with alternate in it. If it does it has the right link node. Here is the code:

NSMutableArray *link; if ([elementName isEqualToString:@"link"]) if (!link) link = [[NSMutableArray alloc] init]; NSString *alternate = [attributeDict objectForKey:@"rel"]; if([alternate isEqualToString:@"alternate"]){ NSString *href = [attributeDict objectForKey:@"href"]; alternate = NULL; } 
Jos
  • 2,421
  • 5
  • 26
  • 30