Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
A simple Python XML to Dictionary parser.
The package is based on this answer from Stack Overflow. It parses entities as well as attributes following this XML-to-JSON "specification".
I just added the from_nest function, which lets you retrieve a value from the nested dictionaries.
pip3 install xml_to_dict --user
from xml_to_dict import XMLtoDict
sample_xml = (
'<response>'
'<results>'
'<user>'
'<name>Ezequiel</name>'
'<age>33</age>'
'<city>San Isidro</city>'
'</user>'
'<user>'
'<name>Belén</name>'
'<age>30</age>'
'<city>San Isidro</city>'
'</user>'
'</results>'
'</response>'
)
parser = XMLtoDict()
print(parser.parse(sample_xml)) # {'response': {'results': {'user': [{'name': 'Ezequiel', 'age': '33', 'city': 'San Isidro'}, {'name': 'Belén', 'age': '30', 'city': 'San Isidro'}]}}}
print(parser.value_from_nest('.*ser', sample_xml)) # [{'name': 'Ezequiel', 'age': '33', 'city': 'San Isidro'}, {'name': 'Belén', 'age': '30', 'city': 'San Isidro'}]
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
Distributed under the MIT License. See LICENSE
for more information.
FAQs
A simple Python XML to Dictionary parser
We found that xml-to-dict demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.