diff --git a/onadata/libs/renderers/renderers.py b/onadata/libs/renderers/renderers.py index b8833eea40..297f7de322 100644 --- a/onadata/libs/renderers/renderers.py +++ b/onadata/libs/renderers/renderers.py @@ -408,7 +408,9 @@ def _to_xml(self, xml, data): elif isinstance(data, dict): for key, value in data.items(): - if isinstance(value, (list, tuple)): + if not key: + self._to_xml(xml, value) + elif isinstance(value, (list, tuple)): for v in value: xml.startElement(key, {}) self._to_xml(xml, v) @@ -419,7 +421,6 @@ def _to_xml(self, xml, data): xml.startElement(key, attributes) self._to_xml(xml, value) xml.endElement(key) - else: xml.startElement(key, {}) self._to_xml(xml, value) diff --git a/onadata/libs/serializers/data_serializer.py b/onadata/libs/serializers/data_serializer.py index 495e8ae615..7a3d3cba00 100644 --- a/onadata/libs/serializers/data_serializer.py +++ b/onadata/libs/serializers/data_serializer.py @@ -114,7 +114,7 @@ def to_representation(self, instance): ret = super( DataInstanceXMLSerializer, self).to_representation(instance) if 'xml' in ret: - ret = xmltodict.parse(ret['xml']) + ret = xmltodict.parse(ret['xml'], cdata_key="") # Add Instance attributes to representation instance_attributes = {