Search code examples
iphoneobjective-cioscocoa-touchios4

NSXMLParser Parsing Attributes


How do you extract attributes from XML using NSXML parser??

Heres my xml:

<item>
<title>Button hails 'amazing' win</title>
<description>Jenson Button hailed yesterday's crazy Canadian Grand Prix victory as the best of his Formula One career.
</description>
<link>http://www.skysports.com/story/0,19528,12433_6986809,00.html</link>
<guid isPermaLink="false">12433_6986809</guid>
<pubDate>Mon, 13 Jun 2011 06:21:00 GMT</pubDate>
<category>News Story</category>
<enclosure type="image/jpg" url="http://img.skysports.com/11/06/128x67/Canadian-GP-Jenson-Button-celebrates1_2609288.jpg" length="123456" />
</item>

I need to get the url from the enclosure tags.

Thanks


Solution

  • if([elementName isEqualToString:@"enclosure"])
    {
        NSString *urlValue=[attributeDict valueForKey:@"url"];
        NSString *urlValue=[attributeDict valueForKey:@"type"];
        NSString *urlValue=[attributeDict valueForKey:@"length"];
    }