converts XML elements into their JSON equivalent
Project description
lxml2json
lxml2json is a python package that converts XML elements into their JSON equivalent.
Usage Example:
from lxml2json import convert
from pprint import pprint as pp
xml = '''
<parent>
<c1>a</c1>
<c1>b</c1>
<c1>c</c1>
<c2>
<gc1>d</gc1>
<gc2>e</gc2>
<gc3>f</gc3>
</c2>
<c2>
<gc1>g</gc1>
<gc2>h</gc2>
<gc3>i</gc3>
</c2>
<c3>
<gc1>j</gc1>
<gc1>k</gc1>
<gc1>l</gc1>
</c3>
<c4/>
</parent>'''
d = convert(xml)
pp(d)
{'parent': {'c1': ['a', 'b', 'c'],
'c2': [{'gc1': 'd', 'gc2': 'e', 'gc3': 'f'},
{'gc1': 'g', 'gc2': 'h', 'gc3': 'i'}],
'c3': {'gc1': ['j', 'k', 'l']},
'c4': None}}
Options
lxml2json provides the following optional arguments to modify conversion behavior or output data format:
- ordered: Boolean, defaults to False. Specifies whether to generate output an OrderedDict object.
- noText: Defaults to None. Specifies the value to give to elements that contain no children and no text value.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lxml2json-0.2.0.tar.gz
(3.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lxml2json-0.2.0.tar.gz.
File metadata
- Download URL: lxml2json-0.2.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3674acb427a3bae57dab46594020b0d0a0004868597be42dc8b32b7822db8ec2
|
|
| MD5 |
b79d6014cfd57c0fe97fcd6594439a87
|
|
| BLAKE2b-256 |
ed61f62556caa5e5760198086745412f32fafe3ce4971f9be44dd11099bd0f92
|
File details
Details for the file lxml2json-0.2.0-py2-none-any.whl.
File metadata
- Download URL: lxml2json-0.2.0-py2-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2f4da9c3f18a3e8ad4876d6e5f6bdb5dc354e9a690a3ef0430d83335166aebe
|
|
| MD5 |
7fd58ffb98f1c68f8ccf4e64731d994c
|
|
| BLAKE2b-256 |
03e7fde8d6bff2494626cb8996a851474f760e1816dc8607287e2d50665e88a0
|