Python ET xml creation with multiple values for a REST API

For a REST API I was using code below to check in case multiple "value" were entered for a certain field. Previous version of REST API allowed me to separate values by new line --> dictsum += (line + u'\r\n') Unfortunately seems not same anymore.

Is there any simple way to assign multiple values to a certain xml field?

   for field_name in dictEntity:
        field = ET.SubElement(fields, 'Field')
        field.set('Name', field_name)
        value = ET.SubElement(field, 'Value')
        if isinstance(dictEntity[field_name], list):
            dictsum = u''
            for line in dictEntity[field_name]:
                dictsum += (line + u'\r\n')

            value.text = dictsum

In this case I am still using python 2.7. Any suggestions are welcome :-)



Read more here: https://stackoverflow.com/questions/64396540/python-et-xml-creation-with-multiple-values-for-a-rest-api

Content Attribution

This content was originally published by Marco smdm at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: