iOS NSXMLPARSER Parsing Media Content Tag Inside RSS Feed
Asked Answered
D

1

6

I am using NSXMLParser to parse RSS feed. Earlier i was using the image url from cdata block but now i have come across a feed that has the image url inside

<media:content url="http://cdn.example.com/wp-content/uploads/2013/10/article-2462931-18C5CBC000000578-776_634x452.jpg" medium="image"/>

How do i pick the image url from this tag? This is what i am trying to use inside didStartElement method but its not working:

if ([elementName isEqual:@"media:content"])
    {
        currentString = [[NSMutableString alloc] init];

        // Basically i need the image url string at this point             

        NSString *imageURLString = [self getFirstImageUrl:currentString];
        imageURL = [NSURL URLWithString:imageURLString];
        [self downloadThumbnails:imageURL];
    }

How can i pick the image url string from the media content tag? Thanks!

Despairing answered 17/10, 2013 at 13:7 Comment(0)
D
9

I haven't received any answers but after trying different things, i was able to solve this issue. I am answering my own question now so that if anyone faces the same issue, they can solve this problem without wasting much time as i did.

In didStartElement method of NSXMLParser, i wrote the following:

if ([elementName isEqual:@"media:content"])
    {
        NSString *imageURLString = [attributeDict objectForKey:@"url"];
        NSLog(@"imgURL %@",imageURLString);

        // Here you can use the imageURLString to download the image
    }
Despairing answered 18/10, 2013 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.