从iOS中的RSS Feed获取图像

时间:2014-01-20 19:26:02

标签: ios objective-c xml rss

我目前正在获取RSS Feed中项目的标题,日期和链接。我想将每个项目的图像添加到我的tableview单元格,我知道如何做到这一点。我遇到的问题是弄清楚如何获取图像的网址。

带有图片网址的XML如下所示:

<description>&lt;img src="http://images.cdn.bigcartel.com/bigcartel/product_images/128552379/max_h-300+max_w-300/LipsITUNES.jpg" title="The Lips- Album Numero Dos" align="left" style="margin:0 10px 10px 0;" /&gt;

Picking up where the previous album left off (self-titled, don't go looking for "Album Numero Uno") The Lips return with 12 new songs and their unique blend of indie garage rock. 

Includes the single "Useless" and "My Name Is Suicide."</description>

这也是:

<media:thumbnail height="75" url="http://images.cdn.bigcartel.com/bigcartel/product_images/128552379/max_h-75+max_w-75/LipsITUNES.jpg" width="75"/>
      <media:description type="html">

1 个答案:

答案 0 :(得分:4)

使用didStartElement委托方法。

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI 
 qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict{

   if (nil != qualifiedName)
   {
        elementName = qualifiedName;
   }

   if ( [elementName isEqualToString:@"media:thumbnail"] ) 
   {
        self.currentItem.mediaUrl = [attributeDict valueForKey:@"url"];
   } 
}

请查看此详细信息iPhone RSS Reader Application with source code

相关问题