import xmltodict
import pprint
import json
xml_content = """
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
"""
"\n <note>\n <to>Tove</to>\n <from>Jani</from>\n <heading>Reminder</heading>\n <body>Don't forget me this weekend!</body>\n </note>\n"
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(json.dumps(xmltodict.parse(xml_content)))
('{"note": {"to": "Tove", "from": "Jani", "heading": "Reminder", "body": '
'"Don\'t forget me this weekend!"}}')
dict = xmltodict.parse(xml_content)
OrderedDict([('note',
OrderedDict([('to', 'Tove'),
('from', 'Jani'),
('heading', 'Reminder'),
('body', "Don't forget me this weekend!")]))])
OrderedDict([('to', 'Tove'),
('from', 'Jani'),
('heading', 'Reminder'),
('body', "Don't forget me this weekend!")])
'Tove'