From 2c6eb5aa35a80ec5550973937c26bf2f8011e65d Mon Sep 17 00:00:00 2001 From: Sphynx-Henryay Date: Tue, 4 Sep 2018 03:53:38 +0800 Subject: [PATCH] Determine is_list if first and last children are with same tag --- rest_framework_xml/parsers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rest_framework_xml/parsers.py b/rest_framework_xml/parsers.py index 5454356..51685f4 100644 --- a/rest_framework_xml/parsers.py +++ b/rest_framework_xml/parsers.py @@ -47,8 +47,9 @@ def _xml_convert(self, element): if len(children) == 0: return self._type_convert(element.text) else: - # if the fist child tag is list-item means all children are list-item - if children[0].tag == "list-item": + # check tag of first and last children to determine if it is a list + # also avoid if len( children ) is one + if children[0].tag == children[-1].tag: data = [] for child in children: data.append(self._xml_convert(child))