 struct ArticlePrototype {
     var title: String!
     var description: String!
-    var imageURL: String? // can use placeholder
+    var imageURL: String!
+    var date: String!
+    var articleURL: String!
 }
 
 class ArticleParser: NSObject {

        if elementName == "item" {
            if !self.articleTitle.isEmpty && !self.articleDescription.isEmpty {
                
                let article = ArticlePrototype(title: self.articleTitle, description: self.self.stringByStrippingHTML(articleDescription), imageURL: "")
                
                self.articles.append(article)
                print(self.articleTitle)

        
        return newString
    }
    
    func getImageFromString(input:String) -> String {
        
        // First, get the entire <img> tag containing the image URL
        
        do {
            let regex = try NSRegularExpression(pattern: "<img src=[^>]+>", options: NSRegularExpressionOptions.CaseInsensitive)
            
            let results = regex.matchesInString(input, options: NSMatchingOptions.ReportCompletion, range: NSMakeRange(0, input.characters.count))
            
            if let match = results.first as NSTextCheckingResult! {
                // create temporary NSString to use NSRange for substringWithRange
                let str = input as NSString
                let imgTag = str.substringWithRange(match.range)
                
                // we have the image tag, we need to extract the image URL
                
                do {
                    // find our url, it is encapsolated like "//[url]"
                    let imgRegex = try NSRegularExpression(pattern: "\"//(.*?)\"", options: NSRegularExpressionOptions.CaseInsensitive)
                    
                    let imgResults = imgRegex.matchesInString(imgTag, options: NSMatchingOptions.ReportCompletion, range: NSMakeRange(0, imgTag.characters.count))
                    
                    if let imgMatch = imgResults.first as NSTextCheckingResult! {
                        // create temporary NSString to use NSRange for substringWithRange
                        let tagStr = imgTag as NSString
                        let imgURL = "http:" + tagStr.substringWithRange(imgMatch.range).stringByReplacingOccurrencesOfString("\"", withString: "")
                        
                        return imgURL
                    }
                    
                } catch {
                    print("Error parsing URL from <img> tag: \(error)")
                }
            }
        } catch {
            print("Error parsing <img> tag: \(error)")
        }
        
        return ""
    }
}
