aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/parsers.py
diff options
context:
space:
mode:
authorMichele Lazzeri2012-01-12 13:28:32 +0100
committerMichele Lazzeri2012-01-12 13:28:32 +0100
commit2966c343520147c4027ea48f3fea47913da3ebdb (patch)
tree7e2ea0fcb379010d156c78f2401b2d9f8217e3c7 /djangorestframework/parsers.py
parent6b3792aef27e045a049d6f3bd86d970cb53ea9f5 (diff)
downloaddjango-rest-framework-2966c343520147c4027ea48f3fea47913da3ebdb.tar.bz2
correct complex data xml parsing
Diffstat (limited to 'djangorestframework/parsers.py')
-rw-r--r--djangorestframework/parsers.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/djangorestframework/parsers.py b/djangorestframework/parsers.py
index 79e14260..b99423a0 100644
--- a/djangorestframework/parsers.py
+++ b/djangorestframework/parsers.py
@@ -187,12 +187,11 @@ class XMLParser(BaseParser):
`data` will simply be a string representing the body of the request.
`files` will always be `None`.
"""
- data = {}
tree = ET.parse(stream)
data = self._xml_convert(tree.getroot())
-
+
return (data, None)
-
+
def _xml_convert(self, element):
"""
convert the xml `element` into the corresponding python object
@@ -203,19 +202,15 @@ class XMLParser(BaseParser):
if len(children) == 0:
return self._type_convert(element.text)
else:
- if element.tag == "resource":
+ # if the fist child tag is list-item means all children are list-item
+ if children[0].tag == "list-item":
data = []
for child in children:
- data.append(self._xml_convert(child))
+ data.append(self._xml_convert(child))
else:
- if children[0].tag == "resource":
- data = []
- for child in children:
- data.append(self._xml_convert(child))
- else:
- data = {}
- for child in children:
- data[child.tag] = self._xml_convert(child)
+ data = {}
+ for child in children:
+ data[child.tag] = self._xml_convert(child)
return data