Skip to content

Instantly share code, notes, and snippets.

@mkorthof
Last active December 20, 2023 19:49
Show Gist options
  • Save mkorthof/dd1dfbda7051301ad23f08d439919346 to your computer and use it in GitHub Desktop.
Save mkorthof/dd1dfbda7051301ad23f08d439919346 to your computer and use it in GitHub Desktop.
conv json to xml
#!/usr/bin/python3
# Source: https://github.com/quandyfactory/dicttoxml/blob/master/README.markdown
# page = urllib.urlopen('http://quandyfactory.com/api/example')
import json
import urllib
import dicttoxml
import sys
if (len(sys.argv) > 1):
page = open(sys.argv[1])
else:
#page = open('/home/$USER/tmp/db_out.json')
page = open('/tmp/db_out.json')
content = page.read()
obj = json.loads(content)
print(obj)
xml = dicttoxml.dicttoxml(obj)
print(xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment