Skip to main content

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.

Release files for lxml2json 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lxml2json 0.2.0
File Size Uploaded
lxml2json-0.2.0.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lxml2json 0.2.0
File Interpreter ABI Platform
lxml2json-0.2.0-py2-none-any.whl Python 2 none any Details

Total release size: 6.7 kB

Release files / lxml2json-0.2.0.tar.gz

Download URL lxml2json-0.2.0.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3674acb427a3bae57dab46594020b0d0a0004868597be42dc8b32b7822db8ec2
BLAKE2b-256 checksum
How to use checksums
ed61f62556caa5e5760198086745412f32fafe3ce4971f9be44dd11099bd0f92
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / lxml2json-0.2.0-py2-none-any.whl

Download URL lxml2json-0.2.0-py2-none-any.whl
Size 3.6 kB
Tags Python 2
SHA-256 checksum
How to use checksums
b2f4da9c3f18a3e8ad4876d6e5f6bdb5dc354e9a690a3ef0430d83335166aebe
BLAKE2b-256 checksum
How to use checksums
03e7fde8d6bff2494626cb8996a851474f760e1816dc8607287e2d50665e88a0
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page