title: Deserialize XML into object structure including dictionary
body: <p>I'm trying to deserialize a given XML File into an object structure.</p>
  
  <p>This is the XML:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;StaticData&gt;
    &lt;Configuration&gt;
      &lt;SqlCmdParameters /&gt;
      &lt;Tables&gt;
        &lt;Table Schema="dbo" Name="table1"&gt;
          &lt;Columns&gt;
            &lt;Column Name="tab1col1" IsPrimaryKey="false" /&gt;
            &lt;Column Name="tab1col2" IsPrimaryKey="false" /&gt;
          &lt;/Columns&gt;
        &lt;/Table&gt;
        &lt;Table Schema="dbo" Name="table2"&gt;
          &lt;Columns&gt;
            &lt;Column Name="tab2col1" IsPrimaryKey="false" /&gt;
            &lt;Column Name="tab2col2" IsPrimaryKey="false" /&gt;
          &lt;/Columns&gt;
        &lt;/Table&gt;
      &lt;/Tables&gt;
    &lt;/Configuration&gt;
    &lt;TableDataItems&gt;
      &lt;TableData Schema="dbo" Name="table1"&gt;
        &lt;RowData tab1col1="11" tab1col2="text1" tab1col3="anotherText1" /&gt;
        &lt;RowData tab1col1="12" tab1col2="text2" tab1col3="anotherText2"/&gt;
        &lt;RowData tab1col1="13" tab1col2="text3" tab1col3="anotherText3"/&gt;
  
      &lt;/TableData&gt;
      &lt;TableData Schema="dbo" Name="table2"&gt;
        &lt;RowData tab2col1="22" tab2col2="text1" /&gt;
        &lt;RowData tab2col1="23" tab2col2="text1" /&gt;
        &lt;RowData tab2col1="24" tab2col2="text1" /&gt;
      &lt;/TableData&gt;
    &lt;/TableDataItems&gt;
  &lt;/StaticData&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The classes I want to fill them in are:</p>
  
  <pre><code>    [XmlRoot("StaticData")]
  public class StaticData
  {
      [XmlElement("Configuration")]
      public Configuration Configuration { get; set; }
  
      [XmlElement("TableDataItems")]
      public TableDataItems TableDataItems { get; set; }
  }
  
  public class Configuration
  {
      [XmlElement("Tables")]
      public List&lt;Table&gt; Tables { get; set; }
  
      [XmlElement("SqlCmdParameters")]
      public List&lt;SqlCommandParameter&gt; SqlCommandParameters { get; set; }
  }
  
  public class TableDataItems
  {
      [XmlElement("TableData")]
      public List&lt;Table&gt; TableDatas { get; set; }
  }
  
  public class Table
  {
      [XmlAttribute("Name")]
      public string TableName { get; set; }
  
      [XmlAttribute("Schema")]
      public string SchemaName { get; set; }
  
      [XmlElement("Columns")]
      public List&lt;Column&gt; Columns { get; set; }
  
      [XmlElement("RowData")]
      public List&lt;Row&gt; Rows { get; set; }
  
      public Table()
      {
          Columns = new List&lt;Column&gt;();
          Rows = new List&lt;Row&gt;();
      }
  }
  
  public class Column
  {
      [XmlAttribute("Name")]
      public string Name { get; set; }
  
      [XmlAttribute("IsPrimaryKey")]
      public bool IsPrimaryKey { get; set; }
  }
  
  public class Row
  {
      public Row()
      { 
          RowData = new Dictionary&lt;string, string&gt;();
      }
      ???What Attribute should I put here???
      public Dictionary&lt;string, string&gt; RowData { get; set; }
  }
  </code></pre>
  
  <p>So, everything works fine until I get to the  where all the Attributes should be filled into a dictionary.</p>
  
  <p>This is how I deserialize the XML so far:</p>
  
  <pre><code>public void CreateObjectStructureFromXml()
      {
          using (TextReader textReader = new StringReader(XmlDocument.ToString()))
          {
              XmlSerializer serializer = new XmlSerializer(typeof(StaticData));
              StaticData = (StaticData) serializer.Deserialize(textReader);
          }
      }
  </code></pre>
  
  <p>I get an exception as soon as I get to the Row elements.</p>
  
  <p>Can anybody please point me to where I made the mistake or what I should do?
  The XML RowData can come with a variable amount of attributes. The attributes are the content of a database table.</p>
  
  <p>Thanks a lot in advance</p>