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 working on getting the URL from the following inside an XML:

Code:
<item>
		<title>Accomidations on Your Trip</title>
<link>http://treymorgan.podbean.com/2012/06/05/accomidations-on-your-trip/</link>
		<enclosure url="http://treymorgan.podbean.com/mf/feed/bf8mvq/Accommoditions.mp3" length="29865594" type="audio/mpeg"/>
				</item>

I just need the URL of the mp3. I am using GDataXML and I know I need to use GDataXMLNode to get the attributeForName enclosure, but not sure how to do it. Right now I have:

Code:
- (void)parseRss:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
    
    NSArray *channels = [rootElement elementsForName:@"channel"];
    for (GDataXMLElement *channel in channels) {            
        
        NSString *blogTitle = [channel valueForChild:@"title"];                    
        
        NSArray *items = [channel elementsForName:@"item"];
        for (GDataXMLElement *item in items) {
            NSString *articleTitle = [item valueForChild:@"title"];
            NSString *articleUrl = [item valueForChild:@"link"];            
           
            GDataXMLNode *nodes = [item attributeForName:@"enclosure"];
            NSLog(@"%@", nodes);

        }      
    }
    
}
The NSLog comes back as null for each entry...Any thoughts?
 
"enclosure" isn't an attribute name. It's an element name. The "enclosure" element has attributes (url, length, type), but "enclosure" is not an attribute itself. The "enclosure" element is also an empty-element, but this has no bearing on the problem or a solution.

What are the values of articleTitle and articleUrl at each iteration?
What is the expected output for the given XML input?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.