Skip to content

fernandoflorez/dict2xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

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).

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages