Python has a json library where you can do json.loads(s) to load json into a python data structure consisting of lists and maps. Is there something equivalent for xml? All the xml libraries I’ve seen map to a DOM where you have to know special API functions, which is IMO less easy to work with.
Python has a json library where you can do json.loads(s) to load json into
Share
No, on the simple note that JSON objects directly translate to Python objects. How do you turn XML into Python – the answer is the DOM.
There are, however, simpler ways to work with XML. The best, in my opinion, for ease of use, is
xml.etree.ElementTree, which allows you to iterate through the elements of the XML and create a tree, which is pretty easy to work with comparable with other ways of getting at XML data.