It’s been said that “telling a programmer there’s already a library to do X is like telling a songwriter there’s already a song about love”.
I recently found myself in need of some code to do simple XML to Python dictionary (and vice-versa) conversions for a small automation app I was writing. There were a few solutions out there; most of which left much to be desired. The exception was Martin Blech’s XMLtoDict, which is an excellent module (it is the de facto standard and used by everybody), but had to be downloaded/used as a module and was several times the size of my original script. So I did what any aspiring developer would do, I rolled my own.
TinyXMLtoDict (TXD) is a skinny XML to Python dictionary converter which works in Python2 or Python3 and requires no non-native libraries/modules. It was built to do XML conversions for simple data structures (like REST calls) whilst being very lightweight, portable, understandable, and requiring as few external dependencies as possible (you don’t need to install anything).
Get the Code
You can visit the GitHub repo at https://github.com/packetsar/tinyxmltodict
Or clone the repo: git clone https://github.com/packetsar/tinyxmltodict.git
If you use the code and see a problem, please report it as an issue on GitHub. Or better yet, fork the repo and create a pull request.