title: Convert XML tree to nested Dictionary
body: <p>I'd like to convert a XML file to a Dictionary. The XML file is strucured as follows.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
  &lt;Definitions&gt;   
      &lt;Organization ID="201"&gt;
          &lt;Department Name="Facility"&gt;
              &lt;Employees&gt;200&lt;/Employees&gt;
              &lt;Building&gt;3&lt;/Building&gt;
              &lt;Obj&gt;classnameA&lt;/Obj&gt;
          &lt;/Department&gt;
          &lt;Department Name="IT"&gt;
              &lt;Employees&gt;12&lt;/Employees&gt;
              &lt;Building&gt;2&lt;/Building&gt;
              &lt;Obj&gt;classnameB&lt;/Obj&gt;
          &lt;/Department&gt;
      &lt;/Organization&gt; 
  &lt;/Definitions&gt;
  </code></pre>
  
  <p>I'd like to use a nested dictionary, which can be conceptualized as a table such that "Department" is the row number, "Organization" is the column number, and "Employees", "Building", and "Obj" are the values to be found there. Therefore, I create the following class (with the help of <a href="https://stackoverflow.com/questions/1918742/elegant-way-to-create-a-nested-dictionary-in-c-sharp">this thread</a>):</p>
  
  <pre><code>public class NestedDictionary&lt;K1, K2, V&gt; :
   Dictionary&lt;K1, Dictionary&lt;K2, V&gt;&gt; { }
  </code></pre>
  
  <p>Then, I need to convert the content of my XML file to <em>NestedDictionary</em> by iterating though the tree. How can I add the three attributes "Employees", "Building", and "Obj" to the my Dictionary?</p>
  
  <pre><code>private static void XmlToDict(XmlNode definitions)
  {
      NestedDictionary&lt;int, string, string&gt; dictionary = new NestedDictionary&lt;int, string, string&gt;();
  
      foreach (XmlNode idNode in definitions)
      {
          foreach (XmlNode nameNode in idNode)
          {
              // The following line does not work
              dictionary.Add(idNode.Name, nameNode.Name, nameNode);
          }
      }
  }
  </code></pre>