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
我正在使用NSXMLParser来解析RSS提要。早些时候我正在使用来自cdata块的图片网址,但现在我遇到了一个内部有图片网址的Feed
<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:
如何从此标记中选择图像网址?这是我想在didStartElement方法中使用但它无法正常工作:
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!
如何从媒体内容标签中选择图片网址字符串?谢谢!
1 个解决方案
#1
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:
在NSXMLParser的didStartElement方法中,我写了以下内容:
if ([elementName isEqual:@"media:content"])
{
NSString *imageURLString = [attributeDict objectForKey:@"url"];
NSLog(@"imgURL %@",imageURLString);
// Here you can use the imageURLString to download the image
}
#1
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:
在NSXMLParser的didStartElement方法中,我写了以下内容:
if ([elementName isEqual:@"media:content"])
{
NSString *imageURLString = [attributeDict objectForKey:@"url"];
NSLog(@"imgURL %@",imageURLString);
// Here you can use the imageURLString to download the image
}