Skip to content


Subversion checkout URL

You can clone with
Download ZIP
simplistic json -> xml converter
branch: master

doc fix

latest commit 0372f1241e
@edsu authored
Failed to load latest commit information.
.gitignore inital docfix doc fix
tweet.json removed, etc
tweet.xml use types module, handle LongType and NoneType


A simplistic JSON to XML converter, created mainly as a way to kill time one evening after a tweet from @pbinkley. Yes, you are entitled to ask why I would ever want to convert JSON to XML. No, I'm not going to provide an answer :-)


From the command line:

% ./ tweet.json | xmllint --format - > tweet.xml

Or from your program:

from json2xml import json2xml

print json2xml("tweet.json", tag_name="tweet")

Or if you have a python data structure created by something like json.loads and you would like xml for it, get a TreeBuilder for it:

from json2xml import data2builder
from xml.etree.ElementTree import tostring

data = {"foo": "bar", "baz": [1, 2, 3]}
builder = data2builder(data, tag_name="data")
doc = builder.close()
print tostring(doc)
Something went wrong with that request. Please try again.