title: Deserialize XML Attributes to Dictionary<string, object>
body: <p>Suppose I am trying to deserialize the following XML (in a C# program):</p>
  
  <pre><code>&lt;Data&gt;
      &lt;DataItem Id="1" Attrib1="Val1_1" Attrib2="Val2_1" Attrib3="Val3_1" /&gt;
      &lt;DataItem Id="2" Attrib1="Val1_2" Attrib4="Val4_2" /&gt;
      &lt;DataItem Id="3" Attrib3="Val3_1" Attrib5="Val5_3" /&gt;
  &lt;/Data&gt;
  </code></pre>
  
  <p>So, each <code>DataItem</code> element will have an <code>Id</code> field and a random set of attributes I'd like to capture / store. </p>
  
  <p>I'm imagining the final containing classes could look as follows:</p>
  
  <pre><code>[XmlRootAttribute("Data")]
  public class Data
  {
      [XmlElement("DataItem")]
      public DataItem[] Items { get; set; }
  }
  
  public class DataItem
  {
      public Dictionary&lt;string, object&gt; Vals { get; set; }
  
      [XmlIgnore]
      public string Id { get { return (string)Vals[Id]; } }
  }
  </code></pre>
  
  <p>(If I'm wrong on this structure, PLEASE let me know - this is still all very new to me!!)</p>
  
  <p>But I'm not sure how to deserialize the attributes into the <code>[Key][Value]</code> pairs for my dictionary.
  I found <a href="https://stackoverflow.com/q/3123921/1693085">this question</a> and also <a href="https://stackoverflow.com/a/5996183/1693085">this other answer</a> that seem to be pointing me in the right (albeit different) directions, but I'm lost in how to implement this correctly and know this should be fairly easy.</p>
  
  <p>Any help / links / samples on how this could be done would be GREATLY appreciated!!</p>
  
  <p>Thanks!!!</p>