title: Converting an XML-document to a dictionary
body: <p>I do not need to edit any XML-file or anything, this is only for reading and parsing. </p>
  
  <p>I want to be able to handle the XML-document as a dictionary, like: <code>username = doc["username"];</code>, but I can't find out how to "convert" the document. I've also encountered the problem with duplicate key-names, but that could be easlily avoided by appending each value with 1, 2 etc; making it easy to for-loop through too.</p>
  
  <p>Is this possible? To treat the (parsed) XML-document as a dictionary?</p>
  
  <hr>
  
  <p>Answer to Mehrdad:
  It varies from time to time, it depends on the request from the user. If the user requests <code>x</code>, then it will be:</p>
  
  <pre><code>&lt;xml&gt;
      &lt;test&gt;foo&lt;/test&gt;
      &lt;bar&gt;123&lt;/bar&gt;
      &lt;username&gt;foobar&lt;/username&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <p>But if he requests <code>y</code>, it will be like</p>
  
  <pre><code>&lt;xml&gt;
      &lt;ammount&gt;1000&lt;/ammount&gt;
      &lt;mail&gt;...@...&lt;/mail&gt;
      &lt;username&gt;foobar&lt;/username&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <hr>
  
  <p>The best would be if this:</p>
  
  <pre><code>&lt;xml&gt;
  &lt;mengde&gt;100&lt;/mengde&gt;
  &lt;type&gt;3&lt;/type&gt;
  &lt;mail&gt;foo&lt;/mail&gt;
  &lt;crypt&gt;bar&lt;/crypt&gt;
  &lt;username&gt;bar&lt;/username&gt;
  &lt;/xml&gt;"
  </code></pre>
  
  <p>Could be parsed and then accessed as <code>doc["mengde"]</code> etc.</p>