Skip to content

Commit

Permalink
Set cdata_key to an empty string
Browse files Browse the repository at this point in the history
- Check if key is an empty string before creating an XML Element
  • Loading branch information
DavisRayM committed May 17, 2021
1 parent d685a41 commit 2a70592
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions onadata/libs/renderers/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion onadata/libs/serializers/data_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 2a70592

Please sign in to comment.