Skip to main content

Utilities for building ElementTrees

Project description

Build Status PyPI version

Klon is a collection of utilities for building ElementTrees.

from klon import build_etree

etree = build_etree(
    'html',
    [
        'head',
        ['title', 'Test Document'],
    ],
    [
        'body',
        ['h1#title', 'This is a test'],
        ['img', {'src': 'https://website.com/image'}],
    ]
)

Under the hood this just builds the tree using the standard xml.etree.ElementTree.Element()

If you change the import line instead to this:

from klon.lxml import build_etree

then you get a version with the same interface but that builds the tree using lxml.etree.Element() instead (note that you don't need LXML installed if you're not using klon.lxml).

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

klon-1.0.0.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

klon-1.0.0-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page