Skip to main content

Fast XML to Python (and vise versa) converter and filter. Written in C++ using Expat SAX parser

Project description


nkit4py - is a nkit C++ library port to Python (see

With nkit4py module you can convert XML string to Python data and vise versa.

With XML-to-Python-data possibilities you can:

- Simply convert XML to Python data with the same structure.
Usual Python Dict objects as well as collections.OrderedDict objects can be created.

- Convert XML to Python data with the structure, which is different from the structure
of XML source (using mapping).

- Create multiple Python structures from one XML source.

- Explicitly identify those elements and attributes in XML source that you
want to use for building Python data structures.
Thus, it's possible to filter out unnecessary XML-data.

- Explicitly define Python type of scalar (primitive) data,
fetched from XML source.
Integers, numbers, strings, datetimes and booleans are supported.

- Control progress of chunked download and parsing of big XML string

- With extra options you can tune some aspects of conversion:
- trim text data
- explicitly define white space characters for trim option
- choose unicode or string type for text data
- define special key to collect all element attributes

Conversion is carried out using SAX parser Expat, so it's fast and uses less
memory when parsing huge XML files.

Module supports not only native Expat XML encodings, but also many others
(see /deps/nkit/src/encoding/

With Python-data-to-XML possibilities you can:

- Create xml string with the same structure as Python data
- Define root element name of result xml string
- Define default element name for list items
- Define encoding of result xml string
- Pretty print with custom indentation and newline characters
- Define special object key name for attributes
- Define special object key name for text
- Define which elements of result xml string must contain CDATA section
- Define precision for float numbers
- Define format for Date objects
- Define representation for *True* and *False* values
- Explicitly define order in which DICT keys will be printed to XML text


On Linux and Mac OS

pip install nkit4py

On Windows

Library compiles on MSVS Express version >= 2012.

For MSVS 2012:


pip install nkit4py

For MSVS 2013:


pip install nkit4py



Python version support


Boris T. Darchiev (

On github:

Any feedback or pull request are welcome!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions (368.1 kB view hashes)

Uploaded source

nkit4py-2.4.2.tar.gz (282.0 kB view hashes)

Uploaded source

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