title: VB.net XML Serialization/Deserialization, How to Put Attributes for Lists
body: <p>If I wanted to serizlize and deserialize an XML like this in VB:</p>
  
  <pre><code>  &lt;SeveralListsOfPeople&gt;
        &lt;ListOfPeople groupname="Friends"&gt;
            &lt;Person name="John"&gt;
            &lt;/Person&gt;
            &lt;Person name="Mary"&gt;
            &lt;/Person&gt;
        &lt;/ListOfPeople&gt;
        &lt;ListOfPeople groupname="Family"&gt;
            &lt;Person name="Karen"&gt;
            &lt;/Person&gt;
            &lt;Person name="Kyle"&gt;
            &lt;/Person&gt;
            &lt;/ListOfPeople&gt;
        &lt;ListOfPeople groupname="Enemies"&gt;
            &lt;Person name="Ben"&gt;
            &lt;/Person&gt;
            &lt;Person name="Chris"&gt;
            &lt;/Person&gt;
        &lt;/ListOfPeople&gt;
      &lt;/SeveralListsOfPeople&gt;
  </code></pre>
  
  <p>How would I add the attribute "groupname" to "ListsOfPeople"?  I can't figure out how to add attributes to lists or arrays.  I only know how to add attributes to objects and the root.</p>
  
  <p>This is how I thought it should work:</p>
  
  <pre><code>Imports System.Xml.Serialization
  
  &lt;Serializable&gt;
  &lt;XmlRoot("SeveralListsOfPeople")&gt;
  Public Class SeveralListsOfPeople
      Public Property ListOfPeople As List(Of Person)
      &lt;XmlAttribute("groupname")&gt; Public Property name() As String
      Public Sub New()
      End Sub
  End Class
  
  &lt;Serializable&gt;
  Public Class Person
      Public Property title As String
      Public Property age As String
      &lt;XmlAttribute("name")&gt; Public Property name() As String
      Public Sub New()
      End Sub
  End Class
  </code></pre>