Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

DSL for creating structured documents in python.

Project Description


DataTree is a DSL for creating structured documents in python. Inspired by ruby builder but with the goal of reducing the amount of line noise associated with creating XML documents in python. As an added bonus the tree can be output to to any structured format (with XML, JSON and YAML supported in the library).

Note: More documentation is coming soon but for now a very basic rough draft can be found at


You can install via PyPi or direct from the github repo.

To install with pip:

$ pip install datatree

To install with easy_install:

$ easy_install datatree


A small example:

from datatree import Tree, Node

tree = Tree()
with as author:'Terry Pratchett')
    author // "Only 2 books listed"
    with author.novels(count=2) as novels:
        novels.novel('Small Gods', year=1992)
        novels.novel('The Fifth Elephant', year=1999)
        novels << Node("novel", "Guards! Guards!", year=1989)

print tree(pretty=True)

Which produces the XML:

    <name>Terry Pratchett</name>
    <!-- Only 2 books listed -->
    <novels count="2">
        <novel year="1992">Small Gods</novel>
        <novel year="1999">The Fifth Elephant</novel>
        <novel year="1989">Guards! Guards!</novel>

Or the JSON:

    "author": {
        "genre": "Fantasy/Comedy",
        "name": "Terry Pratchett",
        "novels": [
            "Small Gods",
            "The Fifth Elephant",
            "Guards! Guards!"

Or the YAML:

  genre: Fantasy/Comedy
  name: Terry Pratchett
  novels: [Small Gods, The Fifth Elephant, Guards! Guards!]


This work is licensed under the Apache License, Version 2.0.

Souce Code

The source code can be found on github.


I welcome any and all constructive feedback. Feel free to contact me (Jason Webb) at or on twitter @bigjasonwebb.


Contributions are welcome. Just fork on github and I will try to be as responsive as possible.

Release History

This version
History Node

History Node


History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(12.5 kB) Copy SHA256 Hash SHA256
Source None Jun 26, 2011

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers