Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

small script to output xml as a string from a python dictionary

Project description

Super Simple utility to convert a python dictionary into an xml string


Make youself a virtualenv and do the following:

$ pip install .

Or if you want to develop on dict2xml, recommended commands are:

$ pip install -e .
$ pip install -e ".[tests]"

Or if you don’t want to install from source:

$ pip install dict2xml


from dict2xml import dict2xml as xmlify
data = {
    'a' : 1
  , 'b' : [2, 3]
  , 'c' : {
      'd' : [
          {'p' : 9}
        , {'o' : 10}
      , 'e': 7

print xmlify(data, wrap="all", indent="  ")




dict2xml.dict2xml(data, *args, **kwargs)

Equivalent to:

dict2xml.Converter(*args, **kwargs).build(data)
dict2xml.Converter(wrap="", indent="  ", newlines=True)

Knows how to convert a dictionary into an xml string

  • wrap: Wraps the entire tree in this tag
  • indent: Amount to prefix each line for each level of nesting
  • newlines: Whether or not to use newlines
Instance method on Converter that takes in the data and creates the xml string


  • No attributes on elements
  • Currently no explicit way to hook into how to cope with your custom data
  • Currently no way to insert an xml declaration line


  • Include readme and LICENSE in the package
  • No code changes
  • changed the licence to MIT
  • Added more metadata to pypi
  • Enabled travis ci
  • Updated the tests slightly
  • No changelog was kept before this point.

Project details

Download files

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

Files for dict2xml, version 1.6.1
Filename, size File type Python version Upload date Hashes
Filename, size dict2xml-1.6.1.tar.gz (5.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page