python convert dict to xml 1

python convert dict to xml

from dicttoxml import dicttoxml

array = [
    {
        'time': {"hour":"1", "minute":"30","seconds": "40"}
    },
    {
        'place': {"street":"40 something", "zip": "00000"}
    }
]

xml = dicttoxml(array, custom_root='test', attr_type=False)

Here is what the above code is Doing:
1. We’re creating a list of dictionaries.
2. We’re converting the list of dictionaries to XML.
3. We’re specifying the root element of the XML to be ‘test’.
4. We’re specifying that we don’t want to use the type of the data as an attribute.

Similar Posts