title: C# XML Deserialization into multiple objects
body: <p>I am deserializing a given XML file into a single object, which I have working fine. However, I now which to adapt the XML file so that I extra attributes, which should be deserialized into a separate object, so from the one given xml file i can populate two objects, is this possible within one operation?</p>
  
  <p>Here is my current code and XML:</p>
  
  <p>XML As it is now:</p>
  
  <pre><code>&lt;NameCollection&gt;
     &lt;Names&gt;
        &lt;Name&gt;
          &lt;description&gt;&lt;/description&gt;
        &lt;Name&gt;
        &lt;Name&gt;
          &lt;description&gt;&lt;/description&gt;
        &lt;Name&gt;
     &lt;/Names&gt;
  &lt;/NameCollection&gt;
  </code></pre>
  
  <p>XML As I wish it to be:</p>
  
  <pre><code>&lt;NameCollection&gt;
    &lt;GenericName&gt;&lt;/GenericName&gt;
    &lt;GenericDescription&gt;&lt;/GenericDescription&gt;
     &lt;Names&gt;
        &lt;Name&gt;
          &lt;description&gt;&lt;/description&gt;
        &lt;Name&gt;
        &lt;Name&gt;
          &lt;description&gt;&lt;/description&gt;
        &lt;Name&gt;
     &lt;/Names&gt;
  &lt;/NameCollection&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>NameCollection commands;
  
  XMLSerializer serializer = new XMLSerializer(typeof(NameCollection));
  StreamReader streamReader = new StreamReader(xmlpath);
  
  commands = (NameCollection)serializer.Derserialize(streamreader);
  
  streamReader.Close();
  </code></pre>
  
  <p>And the current object:</p>
  
  <pre><code>[Serializable()]
  public class TestCommand
  {
     public string description{get;set;}
  }
  
  [Serializable()]
  [XmlRoot("NameCollection")]
  public class NameCollection
  {
     [XmlArray("Commands")]
     [XmlArrayItem("Command", typeof(TestCommand))]
     public TestCommand[] TestCommand {get;set;}
  }
  </code></pre>
  
  <p>I then wish to add GenericName and GenericDescription attributes to another separate object, this is what im stuck on.</p>