title: Deserialize arbitrary XML
body: <p>I'm working on a general system which requires the ability to deserialize <em>arbitrary</em> XML, meaning I don't know ahead of time what tags/attributes are going to be in the XML document. Ideally, XML like this:</p>
  
  <pre><code>&lt;a att="1"&gt;
    &lt;b /&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>Would become an object like this:</p>
  
  <pre><code>new Tag { name = "a", 
    attributes = new Dictionary&lt;string,string&gt; {{"att", "1"}},
    elements = new List&lt;Tag&gt; { new Tag { name = "b" } } }
  </code></pre>
  
  <p>It's perfectly fine if everything deserializes to strings.</p>