Skip to content

Instantly share code, notes, and snippets.

@mkorthof
Last active December 20, 2023 19:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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