Converting an xml to dictionary

I have an XML file like this: <?xml version="1.0" encoding="UTF-8"?> <items> <item type="dict"> <job_id type="str">id-1</job_id > <title type="str">title-1</title> <desc type="str">desc-1</desc> </item> <item type="dict"> <job_id type="str">id-2</job_id> <title type="str">title-2</title> <desc type="str">desc-2</desc> </item> </items> I want to parse this into a dictionary, in such a way that I can access the job using it’s id. So the dictionary… Read More Converting an xml to dictionary

Python xmltodict shows inconsistent behaviour in XML arrays

I seen some, IMHO, inconsistent behaviour in Python xmltodoct.parse function. When an array has only 1 element, it returns an iterator with the child-elements When an array has more than 1 element, it returns an iterator with the elements in OrderedDict See the example below: import xmltodict if __name__ == "__main__": xml01 = """ <A>… Read More Python xmltodict shows inconsistent behaviour in XML arrays