5

I want to read the url attribute from this element by using NSXMLParser:

<enclosure url="http://www.marketoloji.com/wp-content/uploads/2015/01/IMG_1649-110x110.jpg" length="7113" type="image/jpg"/>

I found this resource on Apple site but it's for obj C, not for Swift:

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/XMLParsing/Articles/HandlingElements.html#//apple_ref/doc/uid/20002265-BCIJFGJI

I know that I should work with attributeDict dictionary in didStartElement method but dont know how.

johncoffey
  • 251
  • 3
  • 12

1 Answers1

7

I learned it and here is the way it works in Swift:

in didStartElement method;

if element.isEqualToString("enclosure") {
        var imgLink = attributeDict["url"] as String
    }
johncoffey
  • 251
  • 3
  • 12
  • this worked for me but I had to remove the isEqualToString and just use a traditional comparison operator so: element == "enclosure" – Dan Beaulieu Apr 23 '15 at 03:03