Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6134635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:22:48+00:00 2026-05-23T17:22:48+00:00

I’m trying to parse an rss feed. I can parse the BBC’s feed ok.

  • 0

I’m trying to parse an rss feed. I can parse the BBC’s feed ok. But when I try and parse the independant’s feed I cannot catch the link to an image I need.
(Source of feed is: http://www.independent.co.uk/sport/football/premier-league/rss)
Here is an extract from the feed. Its 1 item.

<item>
<title>Juventus join race to sign Carlos Tevez claim Corinthians</title>
<guid>http://www.independent.co.uk/sport/football/transfers/juventus-join-race-to-sign- 
carlos-tevez-claim-corinthians-2314261.html</guid>  
<link>http://www.independent.co.uk/sport/football/transfers/juventus-join-race-to-sign- 
carlos-tevez-claim-corinthians-2314261.html</link>
<description>
<img src="http://www.independent.co.uk/multimedia/dynamic/00623/tevez_623081k.jpg"  
style="padding-right:5px;margin-right:5px" align="left" >
<p>
Corinthians president Andres Sanchez claims Juventus have entered the race to 
sign Carlos Tevez but insists his own club will not increase their offer for 
the want-away Argentinian.
</p> </description>
<category>Transfers</category>
<pubDate>Fri, 15 Jul 2011 10:46:12   +0100</pubDate>
</item>

The problem is extracting ‘img src=’ since I want the url to the thumbnail image to display.

I’m parsing the rss feed with NSXMLParser and doing the parsing in there following delegates.

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

if(nil != qualifiedName)
{
    elementName = qualifiedName;
}
if ([elementName isEqualToString:@"item"]) 
{
    self.currentItem = [[[BlogRss alloc]init]autorelease];
}
else if ([elementName isEqualToString:@"media:thumbnail"]) 
{
    self.currentItem.mediaUrl = [attributeDict valueForKey:@"url"];
}   
else if([elementName isEqualToString:@"title"] || [elementName isEqualToString:@"link"] || [elementName isEqualToString:@"guid"] || [elementName isEqualToString:@"pubDate"]) 
{
    self.currentItemValue = [NSMutableString string];

} 
else if ([elementName isEqualToString:@"description"] )
{
    self.currentItemValue = [NSMutableString string];
} 
else 
{
    self.currentItemValue = nil;
}   
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName 
 {
if(nil != qName)
{
    elementName = qName;
}
if([elementName isEqualToString:@"title"])
{
    self.currentItem.title = self.currentItemValue;
}
else if([elementName isEqualToString:@"description"])
{
    self.currentItem.description = self.currentItemValue;
}
else if([elementName isEqualToString:@"link"])
{
    self.currentItem.linkUrl = self.currentItemValue;
}
else if([elementName isEqualToString:@"guid"])
{
    self.currentItem.guidUrl = self.currentItemValue;
}
else if([elementName isEqualToString:@"pubDate"])
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
     self.currentItem.pubDate = [NSDate dateFromInternetDateTimeString:self.currentItemValue formatHint:DateFormatHintRFC822];
    [formatter release];
}
else if([elementName isEqualToString:@"item"])
{
    [[self rssItems] addObject:self.currentItem];
}
}

I’ve NSLog’d out

    else if([elementName isEqualToString:@"description"])
{
    self.currentItem.description = self.currentItemValue;
}

The contents of self.currentItemValue and it does not contain any of the img url text.

What is it that I am missing. Is it not valid XML so using NSXMLParser will never work for me?

Many Thanks,
-Code

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:22:48+00:00Added an answer on May 23, 2026 at 5:22 pm

    I would recommend using an XML wrapper around NSXMLParser.

    The one I have used is TouchXML but there are several others out there.

    Given an xPath (//item in your case); the wrappers will provide you with NSDictionary, so you can retrieve the values using the valueForKey: method of NSDictionary.

    It is a lot easier and reusable than creating a custom parser for your specific class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Does anyone know how can I replace this 2 symbol below from the string
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.