xml2json is a package that converts any xml to json (dict).
Project description
xml2json
xml2json is a package that converts any xml to json (dict)
Requirements
- Python 3.8
- Pipenv
Installation
pip install xml2json
Usage
Example
from xml2json import xml2json
with open('tests/sample.xml', 'r') as f:
m = f.read()
result = xml2json(m)
OrderedDict([('breakfast_menu', OrderedDict([('food', [OrderedDict([('name', 'Belgian Waffles'), ('price', '$5.95'), ('description', 'Two of our famous Belgian Waffles with plenty of real maple syrup'), ('calories', '650')]), OrderedDict([('name', 'Strawberry Belgian Waffles'), ('price', '$7.95'), ('description', 'Light Belgian waffles covered with strawberries and whipped cream'), ('calories', '900')]), OrderedDict([('name', 'Berry-Berry Belgian Waffles'), ('price', '$8.95'), ('description', 'Light Belgian waffles covered with an assortment of fresh berries and whipped cream'), ('calories', '900')]), OrderedDict([('name', 'French Toast'), ('price', '$4.50'), ('description', 'Thick slices made from our homemade sourdough bread'), ('calories', '600')]), OrderedDict([('name', 'Homestyle Breakfast'), ('price', '$6.95'), ('description', 'Two eggs, bacon or sausage, toast, and our ever-popular hash browns'), ('calories', '950')])])]))])
Functions
parse - parses xml string to dictionary
clear_signs - clears parsed xml from props with `sign` , shifts `shift` , escapes `scape`
json_to_xml - converts json to xml
xml2json - uses parse & clear_signs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xml2dictionary-0.0.1.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for xml2dictionary-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc500125c965f07e0af9d21b4b646874eb8ed71023a99964c4979caeeb5a4e0e |
|
MD5 | ca4da2c066c0bc74d9dcdb1e77313572 |
|
BLAKE2b-256 | 2d1777f104c84faeac8880750eb0ee693ac18c524beea3e772ad899dd802ac0f |