def json2xml(dictionary, buffer=None): if buffer is None: buffer = StringIO() for key, value in dictionary.items(): if isinstance(value, basestring): print >> buffer, '<%s>%s' % (key, value, key) continue if value is None: print >> buffer, '<%s/>' % key continue if isinstance(value, dict): print >> buffer, '<%s>' % key json2xml(value, buffer) print >> buffer, '' % key else: # iterables for item in value: json2xml({key: item}, buffer) return buffer.getvalue() if __name__ == '__main__': json = { 'foo': { 'bar': 'fleem', 'item': ('cats', 'dogs', 'pigs')}} print json2xml(json)