def convert_xml_to_list_of_dict(file_name):
"""
Takes xml file path as input and
converts to list of dictionaries
Arguments:
file_name : It takes xml file path as input
Returns:
list_of_dict: list of dictionaries where keys
are tag names and values are respective text of the tag.
"""
tree = ElementTree.parse(file_name)
root = tree.getroot()
list_of_dict = []
for child in root:
subchild_dict = OrderedDict()
for subchild in child:
subchild_dict[subchild.tag] = subchild.text
list_of_dict.append(subchild_dict)
return list_of_dict
#2016/06/22 ymizugaki add begin
评论列表
文章目录