Managing XML Data in iOS(Swift)
<p>I am using Zillow's web-based API to retrieve data about properties.  I am successfully able to get data back using an NSURLSession, however, it is in XML, and I only have experience handling JSON.</p>

<p>How do I organize this data in a more readable form, and more specifically, how do I get the year built (<code>&lt;yearBuilt&gt;2007&lt;/yearBuilt&gt;</code>) value?</p>

<p>NSURLSession Code:</p>

<pre><code>func data_request(){

    let url:NSURL = NSURL(string: url_to_request)!
    let session = NSURLSession.sharedSession()
    let request = NSMutableURLRequest(URL: url)
    request.HTTPMethod = "GET"
    request.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData

    let task = session.dataTaskWithRequest(request) {
        (
        let data, let response, let error) in

        if (error == nil){
            //dataString is our XML data
            let dataString = NSString(data: data!, encoding: NSUTF8StringEncoding)
            print(dataString)
        }
    }
    task.resume()
}
</code></pre>

<p>dataString (XML data) printed in Console:<br><code>Optional(&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;SearchResults:searchresults xsi:schemaLocation="http://www.zillow.com/static/xsd/SearchResults.xsd http://www.zillowstatic.com/vstatic/9b53252/static/xsd/SearchResults.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SearchResults="http://www.zillow.com/static/xsd/SearchResults.xsd"&gt;&lt;request&gt;&lt;address&gt;12572 Cherokee Ln&lt;/address&gt;&lt;citystatezip&gt;Galt, CA&lt;/citystatezip&gt;&lt;/request&gt;&lt;message&gt;&lt;text&gt;Request successfully processed&lt;/text&gt;&lt;code&gt;0&lt;/code&gt;&lt;/message&gt;&lt;response&gt;&lt;results&gt;&lt;result&gt;&lt;zpid&gt;25951952&lt;/zpid&gt;&lt;links&gt;&lt;homedetails&gt;http://www.zillow.com/homedetails/12572-Cherokee-Ln-Galt-CA-95632/25951952_zpid/&lt;/homedetails&gt;&lt;graphsanddata&gt;http://www.zillow.com/homedetails/12572-Cherokee-Ln-Galt-CA-95632/25951952_zpid/#charts-and-data&lt;/graphsanddata&gt;&lt;mapthishome&gt;http://www.zillow.com/homes/25951952_zpid/&lt;/mapthishome&gt;&lt;comparables&gt;http://www.zillow.com/homes/comps/25951952_zpid/&lt;/comparables&gt;&lt;/links&gt;&lt;address&gt;&lt;street&gt;12572 Cherokee Ln&lt;/street&gt;&lt;zipcode&gt;95632&lt;/zipcode&gt;&lt;city&gt;Galt&lt;/city&gt;&lt;state&gt;CA&lt;/state&gt;&lt;latitude&gt;38.299332&lt;/latitude&gt;&lt;longitude&gt;-121.267781&lt;/longitude&gt;&lt;/address&gt;&lt;FIPScounty&gt;6067&lt;/FIPScounty&gt;&lt;useCode&gt;SingleFamily&lt;/useCode&gt;&lt;taxAssessmentYear&gt;2015&lt;/taxAssessmentYear&gt;&lt;taxAssessment&gt;403012.0&lt;/taxAssessment&gt;&lt;yearBuilt&gt;2007&lt;/yearBuilt&gt;&lt;lotSizeSqFt&gt;663418&lt;/lotSizeSqFt&gt;&lt;finishedSqFt&gt;1527&lt;/finishedSqFt&gt;&lt;bathrooms&gt;2.0&lt;/bathrooms&gt;&lt;bedrooms&gt;3&lt;/bedrooms&gt;&lt;totalRooms&gt;6&lt;/totalRooms&gt;&lt;zestimate&gt;&lt;amount currency="USD"&gt;390005&lt;/amount&gt;&lt;last-updated&gt;02/17/2016&lt;/last-updated&gt;&lt;oneWeekChange deprecated="true"&gt;&lt;/oneWeekChange&gt;&lt;valueChange duration="30" currency="USD"&gt;-8580&lt;/valueChange&gt;&lt;valuationRange&gt;&lt;low currency="USD"&gt;370505&lt;/low&gt;&lt;high currency="USD"&gt;409505&lt;/high&gt;&lt;/valuationRange&gt;&lt;percentile&gt;0&lt;/percentile&gt;&lt;/zestimate&gt;&lt;localRealEstate&gt;&lt;region name="Galt" id="24831" type="city"&gt;&lt;zindexValue&gt;281,700&lt;/zindexValue&gt;&lt;links&gt;&lt;overview&gt;http://www.zillow.com/local-info/CA-Galt/r_24831/&lt;/overview&gt;&lt;forSaleByOwner&gt;http://www.zillow.com/galt-ca/fsbo/&lt;/forSaleByOwner&gt;&lt;forSale&gt;http://www.zillow.com/galt-ca/&lt;/forSale&gt;&lt;/links&gt;&lt;/region&gt;&lt;/localRealEstate&gt;&lt;/result&gt;&lt;/results&gt;&lt;/response&gt;&lt;/SearchResults:searchresults&gt;&lt;!-- H:004  T:27ms  S:1131  R:Thu Feb 18 16:33:36 PST 2016  B:4.0.25234-master.df01d52~hotfix_pre.361b6ff --&gt;)(lldb)</code></p>

<p>XML in more readable format(when viewed in browser):
<a href="https://i.stack.imgur.com/FCBwG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FCBwG.png" alt="enter image description here"></a></p>