Skip to main content

A lightweight pythonic standard compliant streaming xml writer

Project description

streamingxmlwriter

License: LGPL-3 https://badge.fury.io/py/streamingxmlwriter.svg https://travis-ci.org/acsone/streamingxmlwriter.svg?branch=master https://coveralls.io/repos/acsone/streamingxmlwriter/badge.svg?branch=master&service=github

A lightweight pythonic standard compliant streaming xml writer.

from io import BytesIO

import streamingxmlwriter

stream = BytesIO()
with streamingxmlwriter.from_stream(stream) as writer:
    writer.start_namespace('myns', 'http://mynamespace.org/')
    with writer.element('myns:root', {'att1': '1'}):
        with writer.element('myns:child1'):
            writer.characters('text content')
        writer.comment(' a comment ')
        with writer.element('myns:child2'):
            writer.characters('text content')
        # shortcut for elements containing a single text node
        writer.text_element('myns:child3', 'text content', {'att2': '2'})

For more API examples, look at the documentation of the StreamingXMLWriter class in core.py.

Under the hood it generates SAX events to the standard xml.sax.saxutils.XMLGenerator. It also provides a from_sax_handler constructor so it can also be used to emit sax events for other purposes than outputing to an io stream.

Python 2 (2.7+) and python 3 (3.3+) are supported.

Supported XML features are:

  • elements

  • attributes

  • text

  • processing instructions

  • comments

  • selectable encoding

  • namespaces for elements and attributes, with or without prefix

Unsupported XML features (yet):

  • DOCTYPE declaration

  • entities

  • CDATA sections

Credits

Author

  • Stéphane Bidoul (ACSONE)

Maintainer

ACSONE SA/NV

This module is maintained by ACSONE SA/NV.

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

streamingxmlwriter-1.0.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

streamingxmlwriter-1.0.0-py2.py3-none-any.whl (4.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file streamingxmlwriter-1.0.0.tar.gz.

File metadata

File hashes

Hashes for streamingxmlwriter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3d68345d35628a60776c359e467d883aa264b7fb0eb772cfccd49fe1ab3897ae
MD5 ca860fb695c875fb99df4cf08621d2e0
BLAKE2b-256 844d05838decadb43601835243e4d88aeeb62cb030949d9b1af0c277c4a8590d

See more details on using hashes here.

File details

Details for the file streamingxmlwriter-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for streamingxmlwriter-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7cd7576f2eb9c8f1510b7cda6f0d4519da50c0f816d788e205fa8d9939247827
MD5 a4bdcbfebc575ceca52825b7f13a02da
BLAKE2b-256 6c7a09ae2cef23249fa6eb7b7c3a64974d1c824ffce22eab6d549083503f9437

See more details on using hashes here.

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