title: Loop through xml NSData variable and get values in swift 2.1
body: <p>I'm new to swift programming. </p>
  
  <p>I wrote a code which gets <code>xml</code> output from <code>rss</code> feed and parse it into <code>NSDATA</code> type,
  then I want to get <code>title</code> and <code>image</code> <code>src</code>  values from it in a loop and send them to a table view to create a list.</p>
  
  <p>when I get those values manually I mean like : </p>
  
  <pre><code>let appName = xml["rss"]["channel"]["item"][0]["title"].element!.text!
  let appUrl = xml["rss"]["channel"]["item"][0]["description"]["img"].element!.attributes["src"]
  </code></pre>
  
  <p>my code works ok and one item creates in table view correctly. 
  but the problem is when I want to get all values from xml file. </p>
  
  <p>I couldn't create and array of the xml which is NSDATA type, not a string to be able to loop through it. </p>
  
  <p>all I could manage to work is the below code which returns all xml tags value which I don't want that : </p>
  
  <pre><code>func enumerate(indexer: XMLIndexer, level: Int) {
                  for child in indexer.children {
                      let appName = child.element!.text
                      let appUrl = child.element!.attributes["src"]
  
  
                      let ap = Apps(name: appName , img : appUrl)
                      self.tableData.append(ap)
  
                      self.tableView.reloadData()
  
                      enumerate(child, level: level + 1)
                  }
              }
  
              enumerate(xml, level: 0)
  </code></pre>
  
  <p>Any Idea how to get those values in a loop without mistaking or getting other values? </p>
  
  <p>here is my code : </p>
  
  <pre><code>     let url = NSURL(string: "http://razavitv.aqr.ir/index/rss/2")
  
          let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
  
  
              let dataString = NSString(data: data!, encoding: NSUTF8StringEncoding) as! String
  
              let processedString = (dataString as NSString).stringByReplacingOccurrencesOfString("&lt;![CDATA[", withString: "").stringByReplacingOccurrencesOfString("]]", withString: "") as String
  
              let data: NSData = processedString.dataUsingEncoding(NSUTF8StringEncoding)!
  
              let xml = SWXMLHash.parse(data)
  
  
  //                    let appName = xml["rss"]["channel"]["item"][0]["title"].element!.text!
  //                    let appUrl = xml["rss"]["channel"]["item"][0]["description"]["img"].element!.attributes["src"]
  //    
  //                    let ap = Apps(name: appName , img : appUrl)
  //                    self.tableData.append(ap)
  //            
  //                    self.tableView.reloadData()
  
  
  
  
              func enumerate(indexer: XMLIndexer, level: Int) {
                  for child in indexer.children {
                      let appName = child.element!.text
                      let appUrl = child.element!.attributes["src"]
  
  
                      let ap = Apps(name: appName , img : appUrl)
                      self.tableData.append(ap)
  
                      self.tableView.reloadData()
  
                      enumerate(child, level: level + 1)
                  }
              }
  
              enumerate(xml, level: 0)
  
  
          }
  
          task.resume()
  </code></pre>