iphoneiosnsxmlparser

Parsing Flickr Image-URL with NSXMLParser


I've the following problem:

I'm parsing an XML File from Flickr API http://api.flickr.com/services/feeds/photos_public.gne?tags= with a specific tag, provided by the user before.

Then I get a XML file where in each <entry> item a line exists like

<link rel="enclosure" type="image/jpeg" href="IMAGEURL">

Is there an easy way to parse this line of code with NSXMLParser? Or should I use another way to get the IMAGEURL?


Solution

  • You should be able to use the delegate method parser:didStartElement:namespaceURI:qualifiedName:attributes: to get that info. The attributes are available in the attributesDict. So you can get the IMAGEURL using,

    NSString * imageURLString = [attributesDict objectForKey:@"href"];
    

    when elementName is "link".