mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-11-04 09:57:55 +03:00 
			
		
		
		
	update author
This commit is contained in:
		
							parent
							
								
									c71b6fb090
								
							
						
					
					
						commit
						f461acbaf2
					
				| 
						 | 
					@ -189,11 +189,38 @@ class XMLParser(BaseParser):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        data = {}
 | 
					        data = {}
 | 
				
			||||||
        tree = ET.parse(stream)
 | 
					        tree = ET.parse(stream)
 | 
				
			||||||
        for child in tree.getroot().getchildren():
 | 
					        data = self._xml_convert(tree.getroot())
 | 
				
			||||||
            data[child.tag] = self._type_convert(child.text)
 | 
					 | 
				
			||||||
        	
 | 
					        	
 | 
				
			||||||
        return (data, None)
 | 
					        return (data, None)
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
					    def _xml_convert(self, element):
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        convert the xml `element` into the corresponding python object 
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        `data` The python object representation of xml `element`.
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        children = element.getchildren()
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if len(children) == 0:
 | 
				
			||||||
 | 
					            return self._type_convert(element.text)
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            if element.tag == "resource":
 | 
				
			||||||
 | 
					                data = []
 | 
				
			||||||
 | 
					                for child in children:
 | 
				
			||||||
 | 
					                    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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return data
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
    def _type_convert(self, value):
 | 
					    def _type_convert(self, value):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        Converts the value returned by the XMl parse into the equivalent
 | 
					        Converts the value returned by the XMl parse into the equivalent
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user