title: Recursively / Dynamically add XML attributes into a single Dynamic Object
body: <p>So i have an XML document that has multiple tiers like this:</p>
  
  <pre><code>&lt;root&gt;
  &lt;Client id='1' name='bob'&gt;
       &lt;health id='1'&gt;
            &lt;ex id='2'\&gt;
            &lt;ex id='3' \&gt;
       &lt;/health&gt;
  &lt;/Client&gt;
  &lt;Client id='1' name='bob'&gt;
       &lt;health id='1'&gt;
            &lt;ex id='2'\&gt;
            &lt;ex id='3' \&gt;
       &lt;/health&gt;
  &lt;/Client&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I am trying to recursively go through the XML document and each attribute to an ExpandoObject and add all sub nodes into an ExpandoObject recursively. So the end result of the above xml would have an ExpandoObject with client attributes and also an ExpandoObject inside of it with attributes of health and 2 expandoObjects with their 'ex' attributes in the health ExpandoObject. So its like putting an XML document inside of a multidimensional Dictionary aka an ExpandoObject. </p>
  
  <p>I am having a lot of trouble with the recursion its confusing me hardcore and I can't seem to get it working. Does anyone know how I can traverse like an XDocument recursively and add an ExpandoObject to itself for every sublevel but if its the same depth level add multiple ExpandoObjects to the object above it? </p>
  
  <p>I know this might confuse you since I am also confused but the end object should look something like this:</p>
  
  <p>Object asd = [Properties of Client] + (ExpandoObject asd2 = [properties of health] + (ExpandoObject asd3 = properties of ex + ExpandoObject asd4 = properties of ex2)</p>