-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple elements of the same name? #59
Comments
Have you tried enabling unique id attributes?: https://github.com/quandyfactory/dicttoxml#unique-id-attributes ? |
I think what @BobStein wants is an option to, when producing XML structures from dicts that contain list values, to generate multiple XML sibling elements for each value, rather than a single element with multiple children following the key-item naming pattern that this library currently produces. I would also like this :) |
Looks like #64 fix it pretty well |
Yes, that looks great! |
I agree, it looks like this issue would be fixed by #64. |
This is exactly what I need fix. Can we merge this one too? Please!!! |
{
"country": [
{
"city": "Chicago"
},
{
"city": "Boston"
}
]
} may be converted to xml <?xml version="1.0" encoding="UTF-8"?>
<root>
<country>
<city>Chicago</city>
</country>
<country>
<city>Boston</city>
</country>
</root> <country>
<city>Chicago</city>
<city>Boston</city>
</country> may be converted to json {
"country": {
"city": [
"Chicago",
"Boston"
]
},
"#omit-xml-declaration": "yes"
} |
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
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?The text was updated successfully, but these errors were encountered: