def xml_start(xml):
'Stores $xml file in $dicc dictionary'
def xml_parse(root, dicc, way=""):
new_way = way + "/" + root.tag
value = []
try:
value = dicc[new_way]
except:
value = []
value.append(root.text)
dicc.__setitem__(new_way, value)
for new_root in root._children:
xml_parse(new_root, dicc, new_way)
tree = ET.parse(xml, parser=None)
root = tree.getroot()
dicc = {}
xml_parse(root, dicc, way="")
return dicc
评论列表
文章目录