Nobody wrote:
The code you're using expects the XML to follow a particular format, and yours doesn't.You might want to start with a fairly direct translation, e.g.: def xmldict(e): d = {} d['tag'] = e.tag d.update(e.attrib) children = map(xmldict, e) if children: d['children'] = children text = e.text.strip() if text: d['text'] = text return d tree = ElementTree.parse('test.xml') root = tree.getroot() d = xmldict(root) pprint.pprint(d) then refine this as needed.
Thanks, that is simple enough for me to understand. I think I got it now. Thanks again -- http://mail.python.org/mailman/listinfo/python-list
