OrderedDict: Unable Return the item of d with key key. Raises a KeyError
问题 Accessing xmltodict converted values. I have an xml that looks like this <PQ N="E90" RT="TG"> <CASES ASOF_DATE="8/11/2017" CREATE_DATE="8/13/2017" RECORDS="1130" > <CASE> <ID>E90</ID> I am trying to access the CASE dictionary. If I remove the second XML line and try returning d[PQ]['CASE'], I get the desire result Here is the code for that: def convert(xml_file, xml_attribs=True): with open(xml_file, "rb") as f: d = xmltodict.parse(f, xml_attribs=xml_attribs) return (d['FUND']) This is how