title: How to serialize a List of Objects returned from a webservice in C# ASP.NET 3.5?
body: <p>Here is the XML that I'd like the webservice to deliver:</p>
  
  <pre><code>&lt;business&gt;
    &lt;locations&gt;
      &lt;location&gt;location 1&lt;/location&gt;
      &lt;location&gt;location 2&lt;/location&gt;
    &lt;/locations&gt;
  &lt;/business&gt;
  </code></pre>
  
  <p>However, instead the following is being returned:</p>
  
  <pre><code>&lt;business&gt;
    &lt;locations&gt;
      &lt;location&gt;
        &lt;name&gt;location 1&lt;/name&gt;
      &lt;/location&gt;
      &lt;location&gt;
         &lt;name&gt;location 2&lt;/name&gt;
      &lt;/location&gt;
    &lt;/locations&gt;
  &lt;/business&gt;
  </code></pre>
  
  <p>Here is the code used:</p>
  
  <pre><code>    [WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
      public Business GetBusiness()
      {
          var business = new Business();
          business.Locations = new List&lt;Location&gt;();
          business.Locations.Add(new Location { Name = "location 1" });
          business.Locations.Add(new Location { Name = "location 2" });
          return business;
      }
  
      [XmlType(TypeName = "business")]
      public class Business
      {
          [XmlArray(ElementName = "locations")]
          [XmlArrayItem(ElementName = "location")]
          public List&lt;Location&gt; Locations { get; set; }
      }
  
      [XmlType(TypeName = "location")]
      public class Location
      {
          [XmlElement(ElementName = "name")]
          public string Name { get; set; }
      }
  </code></pre>
  
  <p>How does one get the location string include the location tag instead of having a name tag?</p>
  
  <p>TIA,
  George</p>