title: iOS: NSXMLParser get attribute
body: <p>I'm really new to this and I'm trying to read an RSS feed, and so far everything is good. This is how I do it:</p>
  
  <pre><code>- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
    if ([elementName isEqualToString:@"item"]) {
      [item setObject:currentTitle forKey:@"title"];
      [item setObject:currentLink forKey:@"link"];
      [item setObject:currentSummary forKey:@"summary"];
      [item setObject:currentDate forKey:@"date"];
      [item setObject:currentImage forKey:@"enclosure"];
  
      [stories addObject:[item copy]];
      NSLog(@"adding story: %@", currentTitle);
    }
  }
  </code></pre>
  
  <p>The problem is the enclosure. Which looks like this in the XML:</p>
  
  <pre><code>&lt;enclosure length="150" url="urltoimage.jpg" type="image/jpeg" /&gt;
  </code></pre>
  
  <p>How do I get <strong>url</strong> attribute from that element from within my function?</p>
  
  <p><strong>EDIT</strong> The XML looks like this:</p>
  
  <pre><code>&lt;item&gt;
      &lt;title&gt;...&lt;/title&gt;
      &lt;link&gt;...&lt;/link&gt;
      &lt;description&gt;...&lt;/description&gt;
      &lt;pubDate&gt;...&lt;/pubDate&gt;
      &lt;enclosure length="150" url="urltoimage.jpg" type="image/jpeg" /&gt;
  &lt;/item&gt;
  </code></pre>
  
  <p>And my foundCharacters function looks like this:</p>
  
  <pre><code>- (void)parser: (NSXMLParser *)parser foundCharacters:(NSString *)string {
    if ([currentElement isEqualToString:@"title"]) {
      [currentTitle appendString:string];
    } else if ([currentElement isEqualToString:@"link"]) {
      [currentLink appendString:string];
    } else if ([currentElement isEqualToString:@"description"]) {
      [currentSummary appendString:string];
    } else if ([currentElement isEqualToString:@"pubDate"]) {
      [currentDate appendString:string];
    }
  }
  </code></pre>