Most viewed recipes by Rodrigo Strauss http://code.activestate.com/recipes/users/2678660/views/2007-06-28T03:16:28-07:00ActiveState Code RecipesConverting XML to dict (for a XPATH-like access syntax) and back to XML (Python)
2007-06-28T03:16:28-07:00Rodrigo Strausshttp://code.activestate.com/recipes/users/2678660/http://code.activestate.com/recipes/522991-converting-xml-to-dict-for-a-xpath-like-access-syn/
<p style="color: grey">
Python
recipe 522991
by <a href="/recipes/users/2678660/">Rodrigo Strauss</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 4.
</p>
<p>I really like config files done in Python language itself, using a dictionary declaration. It's cool for programmers, but not so cool for system administrators not used to Python (it's so easy to forget a comma...).
To keep using dictionaries internally providing something more admin friendly, I've done some functions to convert a XML file to Python dictionary (and the reverse as well):</p>