Convert xml to dict and vice versa.
Latest commit a3c4c0b Mar 11, 2014 @rahulkmr rahulkmr Merge pull request #6 from pierreroth64/master
XML to dict symetric conversion
Failed to load latest commit information.
.gitignore Updating .gitignore. Nov 24, 2011
LICENSE First commit. Nov 24, 2011 Update Jan 27, 2014 Correcting method name s/clean/_clean Feb 14, 2012 Version bump for bug fix. Apr 10, 2013 Remove extra line Feb 10, 2014


Convert xml to python dictionaries, and vice-versa.


pip install xmldict

On most of the systems, you will need the sudo permissions if you are doing a system wide install.

sudo pip install xmldict


# Converting xml to dictionary
>>> xmldict.xml_to_dict('''
... <root>
...   <persons>
...     <person>
...       <name first="foo" last="bar" />
...     </person>
...     <person>
...       <name first="baz" last="bar" />
...     </person>
...   </persons>
... </root>
... ''')
{'root': {'persons': {'person': [{'name': {'last': 'bar', 'first': 'foo'}}, {'name': {'last': 'bar', 'first': 'baz'}}]}}}

# Converting dictionary to xml 
>>> xmldict.dict_to_xml({'root': {'persons': {'person': [{'name': {'last': 'bar', 'first': 'foo'}}, {'name': {'last': 'bar', 'first': 'baz'}}]}}})