title: How to get html attribute value from a string in swift
body: <p>I'm new to swift and need a little help. </p>
  
  <p>I will like to get the src value from an img tag that has been converted to a string using                 </p>
  
  <pre><code>string.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
  </code></pre>
  
  <p>I am retrieving posts from a blog and trying to get the image url from each item, so that I can retrieve the image and display it in an image view.</p>
  
  <p>Here is my code:</p>
  
  <p>class myTableViewController: UITableViewController, NSXMLParserDelegate {</p>
  
  <pre><code>var parser: NSXMLParser = NSXMLParser()
  var blogPosts: [BlogPost] = []
  var postTitle: String = String()
  var eName: String = String()
  
  override func viewDidLoad() {
      super.viewDidLoad()
      let url:NSURL = NSURL(string: "http://myurl.com")!
      parser = NSXMLParser(contentsOfURL: url)!
      parser.delegate = self
      parser.parse()
  }
  
  func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String]) {
      eName = elementName
      if elementName == "item" {
          postTitle = String()
      }
  }
  
  func parser(parser: NSXMLParser, foundCharacters string: String) {
      let data = string.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
      if (!data.isEmpty) {
          if eName == "title" {
              postTitle += data
          } else if eName == "content:encoded" {
              //get the img src from data
  
          }
      }
  }
  </code></pre>
  
  <p>The Blogpost class:</p>
  
  <p>class BlogPost {</p>
  
  <pre><code>var postTitle: String = String()
  </code></pre>
  
  <p>}</p>