Search code examples
iphonexmlrssyoutubefeedparser

MWFeedParser tag inside tag (media:thumbnail)


i am using MWFeedParser to read from Youtube atom feed from here: here

Xml code:

 <media:thumbnail url='http://i.ytimg.com/vi/7_1PfqGVSg0/0.jpg' height='240' width='320' time='00:01:34.500'/>

how i can get the url of media:thumbnail? i tried to change in MWFeedParser.m from this:

else if ([currentPath isEqualToString:@"/feed/entry/link"]) { [self processAtomLink:currentElementAttributes andAddToMWObject:item]; processed = YES; }

to this:

else if ([currentPath isEqualToString:@"/feed/entry/media:thumbnail"]) { [self processAtomLink:currentElementAttributes andAddToMWObject:item]; processed = YES; }

but it doesn't work :(


Solution

  • In the section case FeedTypeAtom add the following code:

    else if ([currentPath isEqualToString:@"/feed/entry/media:group/media:thumbnail"]) {
        NSString *urlString = [currentElementAttributes objectForKey:@"url"];                   
        if ( urlString != nil && urlString.length > 0) 
            item.thumbnail = urlString;  
        processed = YES;
    }
    

    Also add NSString *thumbnail properties to the MWFeedItem object