def _element2dict(self, parent):
d = {}<EOL>for node in parent.childNodes:<EOL><INDENT>if not isinstance(node, minidom.Element):<EOL><INDENT>continue<EOL><DEDENT>if not node.hasChildNodes():<EOL><INDENT>continue<EOL><DEDENT>if node.childNodes[<NUM_LIT:0>].nodeType == minidom.Node.ELEMENT_NODE:<EOL><INDENT>try:<EOL><INDENT>d[node.tagName]<EOL><DEDENT>except KeyError:<EOL><INDENT>d[node.tagName] = []<EOL><DEDENT>d[node.tagName].append(self._element2dict(node))<EOL><DEDENT>elif len(node.childNodes) == <NUM_LIT:1> and node.childNodes[<NUM_LIT:0>].nodeType in [minidom.Node.CDATA_SECTION_NODE, minidom.Node.TEXT_NODE]:<EOL><INDENT>d[node.tagName] = node.childNodes[<NUM_LIT:0>].data<EOL><DEDENT><DEDENT>return d<EOL>
将单个节点转换为 dict