IOS NSXMLPARSER Content Content Analysis Inside RSS Feed

I am using NSXMLParser to parse an RSS feed. I used to use the image url from the cdata block, but now I came 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 to choose image url from this tag? This is what I am trying to use inside the didStartElement method, but does not work:

 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 select the url string of an image from the library tag? Thanks!

+6
source share
1 answer

I did not get any answers, but after trying different things, I was able to solve this problem. I am answering my question now, so if someone is faced with the same problem, they can solve this problem without spending much time like me.

In the didStartElement method for 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 } 
+9
source

Source: https://habr.com/ru/post/956170/


All Articles