I need to generate some XML from a Python dictionary that has multiple elements of the same name.
<country>
<city>Chicago</city>
<city>Boston</city>
</country>
Obviously the following won't work. I assumed it would produce a syntax error, but it simply hides one of the keys:
>>> from dicttoxml import dicttoxml
>>> dicttoxml({'country':{'city':'Chicago', 'city': 'Boston'}}, attr_type=False, root=False)
'<country><city>Boston</city></country>'
I tried a list, but that wraps each list element in an item element:
>>> dicttoxml({ 'country': [ {'city': 'Chicago'}, {'city': 'Boston'} ] }, attr_type=False, root=False)
'<country><item><city>Chicago</city></item><item><city>Boston</city></item></country>'
Here's what I want the output to be
'<country><city>Chicago</city><city>Boston</city></country>'
What dictionary and/or function call settings (e.g. item_func=None) would produce that?
I need to generate some XML from a Python dictionary that has multiple elements of the same name.
Obviously the following won't work. I assumed it would produce a syntax error, but it simply hides one of the keys:
>>> from dicttoxml import dicttoxml>>> dicttoxml({'country':{'city':'Chicago', 'city': 'Boston'}}, attr_type=False, root=False)'<country><city>Boston</city></country>'I tried a list, but that wraps each list element in an
itemelement:>>> dicttoxml({ 'country': [ {'city': 'Chicago'}, {'city': 'Boston'} ] }, attr_type=False, root=False)'<country><item><city>Chicago</city></item><item><city>Boston</city></item></country>'Here's what I want the output to be
'<country><city>Chicago</city><city>Boston</city></country>'What dictionary and/or function call settings (e.g.
item_func=None) would produce that?