Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Pythonic, low noise structured document authoring

tag: v0.1

Fetching latest commit…

Cannot retrieve the latest commit at this time



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

More documentation is coming soon.


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

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)

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>

Or the JSON:

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

Or the YAML:

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


This work is licensed under the Creative Commons Attribution 3.0 Unported License. You can view a copy of this license here.

Souce Code

The source code can be found on github.

Something went wrong with that request. Please try again.