You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears XMLParser() does not support item lists. When parsing an XML list, the parser returns the last list item only (as a dict()). This behaviour is unexpected, and from what i can tell, not documented.
Example code follows:
XML = """<?xml version="1.0" encoding="UTF-8"?>
<root>
<item>
<ID>item_1</ID>
<Description>first item</Description>
</item>
<item>
<ID>item_2</ID>
<Description>second item</Description>
</item>
</root>
"""
from django.conf import settings
settings.configure()
from django.utils.six import BytesIO
from rest_framework_xml.parsers import XMLParser
data_stream = BytesIO(XML)
parsed_data = XMLParser().parse(data_stream)
print parsed_data
Why not include a 'item_tag_name' class property like there is on the XMLRenderer to make it easier to subclass without having to reimplement _xml_convert method?
As described in:
http://stackoverflow.com/questions/35631886/django-rest-xmlparser-cannot-parse-item-list
It appears XMLParser() does not support item lists. When parsing an XML list, the parser returns the last list item only (as a dict()). This behaviour is unexpected, and from what i can tell, not documented.
Which returns:
Given XML lists are common, and the code does not throw a warning/error; I would consider this a bug.
The text was updated successfully, but these errors were encountered: