File size: 311 Bytes
a57c6eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# -*- coding: UTF-8 -*-

"""
__author__ = zhiqiangxia
__date__ = 2020-04-15
"""

import xml.etree.ElementTree as ET
import xmltodict


def read_xml2json(path):
    tree = ET.parse(path)
    root = tree.getroot()
    xmlstr = ET.tostring(root).decode()
    dct = xmltodict.parse(xml_input=xmlstr)
    return dct