How can i convert an xml file into JSON using python?

前端 未结 3 1593
[愿得一人]
[愿得一人] 2021-01-18 04:12

I have an XML file which I want to convert into JSON file using python, but its nt working out for me.



    

        
3条回答
  •  旧巷少年郎
    2021-01-18 05:07

    You can try to use xmljson. The code for the same is

    from xmljson import badgerfish as bf
    from xml.etree.ElementTree import fromstring
    s = '''
    
       Tove
       Jani
       Reminder
       Don't forget me this weekend!
    '''
    json.dumps(bf.data(fromstring(s)))
    

提交回复
热议问题