xmltodict (full disclosure: I wrote it) does exactly that:
xmltodict.parse("""
<?xml version="1.0" ?>
<person>
<name>john</name>
<age>20</age>
</person>""")
# {u'person': {u'age': u'20', u'name': u'john'}}
More Related Contents:
- Split / Explode a column of dictionaries into separate columns with pandas
- Access a particular field in arbitrarily nested JSON data [duplicate]
- Converting dictionary to JSON
- Converting XML to JSON using Python?
- Storing Python dictionaries
- How can I access the nested data in this complex JSON, which includes another JSON document as one of the strings?
- String to Dictionary in Python [duplicate]
- How to dump a dict to a JSON file?
- Convert a python dict to a string and back
- Convert JSON to XML in Python
- Why do I get an error “‘unicode’ object does not support item deletion” when trying to delete values from a JSON object?
- How to json_normalize a column with NaNs
- python: read json and loop dictionary
- JSON dumps custom formatting
- JSON object must be str, bytes or bytearray, not dict
- How to completely traverse a complex dictionary of unknown depth?
- How to convert XML to JSON in Python? [duplicate]
- Pretty print JSON dumps
- Converting xml to dictionary using ElementTree
- Why do I get an error “‘str’ object does not support item deletion” when trying to delete values from a JSON object?
- How to copy a dictionary and only edit the copy
- How to keep track of class instances?
- How do I combine two lists into a dictionary in Python? [duplicate]
- How do I serialize a Python dictionary into a string, and then back to a dictionary?
- Switching into new window using Selenium after button click
- How to create a dictionary of two pandas DataFrame columns
- Simple CSV to XML Conversion – Python
- How can I avoid “RuntimeError: dictionary changed size during iteration” error?
- Is there a way to get a line number from an ElementTree Element
- How to convert only numbers in a mixed list into float