Convert xml to dict and vice versa.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
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 Cleanups in test case Feb 10, 2014 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'}}]}}})