Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
I am trying to parse an xml of a podcast to be able to download or stream an mp3 that is in the xml. Here is part of the code for parsing it:
Code:
- (void)parseAtom:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
    
    NSString *blogTitle = [rootElement valueForChild:@"title"];                    
    
    NSArray *items = [rootElement elementsForName:@"entry"];
    for (GDataXMLElement *item in items) {
        
        NSString *articleTitle = [item valueForChild:@"title"];
        NSString *articleUrl = nil;
        NSArray *links = [item elementsForName:@"guid"];
        for(GDataXMLElement *link in links) {
            NSString *rel = [[link attributeForName:@"rel"] stringValue];
            NSString *type = [[link attributeForName:@"type"] stringValue]; 
            if ([rel compare:@"alternate"] == NSOrderedSame && 
                [type compare:@"text/html"] == NSOrderedSame) {
                articleUrl = [[link attributeForName:@"href"] stringValue];
            }
        }
        
        NSString *articleDateString = [item valueForChild:@"updated"];        
        NSDate *articleDate = [NSDate dateFromInternetDateTimeString:articleDateString formatHint:DateFormatHintRFC3339];
        
        RSSEntry *entry = [[[RSSEntry alloc] initWithBlogTitle:blogTitle 
                                                  articleTitle:articleTitle 
                                                    articleUrl:articleUrl 
                                                   articleDate:articleDate] autorelease];
        [entries addObject:entry];
        
    }      
    
}
Here is one of the 'episodes' from the XML
Code:
<item>

		<title>A Place At His Table</title>
		<link>http://www.smcoc.net/index.php?option=com_biblestudy&view=studydetails&id=299&templatemenuid=20&Itemid=1</link>
		<comments>http://www.smcoc.net/index.php?option=com_biblestudy&view=studydetails&id=299&templatemenuid=20&Itemid=1</comments>

		<itunes:author>Dale Jenkins</itunes:author>
		<dc:creator>Dale Jenkins</dc:creator>
		<description>SUNDAY AM: Dale speaks of God's Grace while comparing our lives to that of David and Mephibosheth</description>
		<content:encoded>SUNDAY AM: Dale speaks of God's Grace while comparing our lives to that of David and Mephibosheth</content:encoded>
		<pubDate>Sun, 26 Feb 2012 11:16:03 -0500</pubDate>
		<itunes:subtitle>A Place At His Table</itunes:subtitle>

		<itunes:summary>SUNDAY AM: Dale speaks of God's Grace while comparing our lives to that of David and Mephibosheth</itunes:summary>
		<itunes:keywords>church of christ, sermon, spring meadows</itunes:keywords>
		<itunes:duration>00:30:15</itunes:duration><enclosure url="http://www.smcoc.net/content/audio/sermons/2012/2012_2_26_a_place_at_his_table.mp3" length="12706816" type="" />
				<guid>http://www.smcoc.net/content/audio/sermons/2012/2012_2_26_a_place_at_his_table.mp3</guid><itunes:explicit>no</itunes:explicit>
	</item>
The didSelectRow code:
Code:
if (_webViewController == nil) {
             self.webViewController = [[[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]] autorelease];
         }
         RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
         _webViewController.entry = entry;
         [self.navigationController pushViewController:_webViewController animated:YES];
However, the URL that gets parsed from all of this is:
Code:
http://www.smcoc.net/index.php?option=com_biblestudy&view=studydetails&id=299&templatemenuid=20&Itemid=1
This is under the <link> tag in the XML. Could someone help me get it properly pointed to either what is in the <enclosure> tag or the <guid> tag?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.