pydict2xml

Small utility to convert a python dict into an xml tree.


License
Other
Install
pip install pydict2xml==0.5.0

Documentation

dict2xml

Small utility to convert a python dict into an xml tree.

Supports node attributes and text nodes.

Uses cElementTree internally so no deps under python 2.5+

Installation

pip install pydict2xml

Examples

from dict2xml import dict2xml
from xml.etree.cElementTree import tostring


tree = {
    'root': {
        'foo': 'bar',
        'children': [
            {
                'name': 'child 1'
            },
            {
                'name': 'child 2'
            }
        ],
        'text_node': {
            '_text': 'This is a test'
        }
    }
}

data = dict2xml(tree)

print data

print tostring(data, encoding='UTF-8')

dict2xml is available under the MIT license (MIT).