XML : XML Parsing in Swift 2 (Xcode 7)

I am needing help parsing XML from a URL. I have read on this a lot and cannot figure out how to get this. All the examples I have found are a little ambiguous with the examples and how to grab the info from parsed XML data.

How would I parse this XML

  <menu>      <menuitems>          <item price="$10">Pizza</item>          <item price="$5">Salad</item>          <item price="$3">Bread</item>      </menuitems>  </menu>    

This is the tutorial I was going off of but I couldn't understand how this tutorial was accessing the data in the arrays and dictionary.

http://www.theappguruz.com/blog/xml-parsing-using-nsxmlparse-swift

In Xcode 7 (Swift 2), how would I parse and access this info. I know this is not how it would be accessed but I am looking for something like the code below.

  print ("\(item[0].data)") // Pizza //  print ("\(item[0].price)") // $10 //    

No comments:

Post a Comment