You can get the xml you expect using the custom_root and item_func arguments to the dicttoxml method:
import dicttoxml
request_dict = ['aaa', 'bbb', 'ccc']
item_name = lambda x: 'key1'
request_xml = dicttoxml.dicttoxml(request_dict, attr_type=False, custom_root='xml', item_func=item_name)
print(request_xml.decode('utf-8'))
Output:
<xml><key1>aaa</key1><key1>bbb</key1><key1>ccc</key1></xml>
An extension to this example is solving the case of multiple repeating keys in a single xml, like defined by <xsd:element minOccurs="0" maxOccurs="unbounded">
which I could neither achieve using OrderedDict from Dave's answer. The closest result is using a the item_func lambda that names the items in the name of the parent:
import dicttoxml
xml_dict = {}
xml_dict['key1'] = ['aaa', 'bbb', 'ccc']
xml_dict['another-key'] = ['a','b','c']
item_name = lambda x: x
request_xml = dicttoxml.dicttoxml(xml_dict, attr_type=False, custom_root='xml', item_func=item_name)
print(request_xml.decode('utf-8'))
But then we you'll have to remove the parents from the result:
<xml>
<key1>
<key1>aaa</key1>
...
Clean up can be applied (explicit):
xml_str = request_xml.decode("utf-8", "strict")
xml_str = xml_str.replace('<key1><key1>', '<key1>').replace('</key1></key1>', '</key1>')
xml_str = xml_str.replace('<another-key><another-key>', '<another-key>').replace('</another-key></another-key>', '</another-key>')
print(xml_str)
Result:
<xml>
<key1>aaa</key1>
...
<another-key>a</another-key>
...
</xml>