title: Parse xml response with XElement into Model class
body: <p>I have the following class:</p>
  
  <pre><code>public class Location
  {
      public string Name { get; set; }
      public long Latitude { get; set; }
      public long Longitude { get; set; }
      public string AddressLine { get; set; }
      public string FormattedAddress { get; set; }
      public string PostalCode { get; set; }
  
  
  }
  </code></pre>
  
  <p>And the following XML response from my RESTful request:</p>
  
  <pre><code>&lt;Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1"&gt;
  &lt;Copyright&gt;Copyright © 2011 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.&lt;/Copyright&gt;
  &lt;BrandLogoUri&gt;http://dev.virtualearth.net/Branding/logo_powered_by.png&lt;/BrandLogoUri&gt;
  &lt;StatusCode&gt;200&lt;/StatusCode&gt;
  &lt;StatusDescription&gt;OK&lt;/StatusDescription&gt;
  &lt;AuthenticationResultCode&gt;ValidCredentials&lt;/AuthenticationResultCode&gt;
  &lt;TraceId&gt;xxx&lt;/TraceId&gt;
  &lt;ResourceSets&gt;
  &lt;ResourceSet&gt;
    &lt;EstimatedTotal&gt;1&lt;/EstimatedTotal&gt;
    &lt;Resources&gt;
      &lt;Location&gt;
        &lt;Name&gt;L4 0TH, Liverpool, Liverpool, United Kingdom&lt;/Name&gt;
        &lt;Point&gt;
          &lt;Latitude&gt;53.431259840726852&lt;/Latitude&gt;
          &lt;Longitude&gt;-2.9616093635559082&lt;/Longitude&gt;
        &lt;/Point&gt;
        &lt;BoundingBox&gt;
          &lt;SouthLatitude&gt;53.427397123156176&lt;/SouthLatitude&gt;
          &lt;WestLongitude&gt;-2.9702530969854752&lt;/WestLongitude&gt;
          &lt;NorthLatitude&gt;53.435122558297529&lt;/NorthLatitude&gt;
          &lt;EastLongitude&gt;-2.9529656301263412&lt;/EastLongitude&gt;
        &lt;/BoundingBox&gt;
        &lt;EntityType&gt;Postcode1&lt;/EntityType&gt;
        &lt;Address&gt;
          &lt;AdminDistrict&gt;England&lt;/AdminDistrict&gt;
          &lt;AdminDistrict2&gt;Liverpool&lt;/AdminDistrict2&gt;
          &lt;CountryRegion&gt;United Kingdom&lt;/CountryRegion&gt;
          &lt;FormattedAddress&gt;L4 0TH, Liverpool, Liverpool, United Kingdom&lt;/FormattedAddress&gt;
          &lt;Locality&gt;Liverpool&lt;/Locality&gt;
          &lt;PostalCode&gt;L4 0TH&lt;/PostalCode&gt;
        &lt;/Address&gt;
        &lt;Confidence&gt;High&lt;/Confidence&gt;
      &lt;/Location&gt;
    &lt;/Resources&gt;
  &lt;/ResourceSet&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>How can I get the value of Name, Latitude, Longitude, AddressLine, FormattedAddress and PostalCode into my properties?</p>
  
  <p>My method is:</p>
  
  <pre><code>internal Location ListLocations()
      {
          Location loc = new Location();
          string query = "L40TH";
          string key = "MyBingMapsKey";
          string url = string.Format("http://dev.virtualearth.net/REST/v1/Locations/{0}?o=xml&amp;key={1}", query, key);
          XElement elements = GetResponse(url);
  
          // stuck here!
  
      }
  </code></pre>