Skip to content

Instantly share code, notes, and snippets.

@mkorthof mkorthof/json2xml.py
Last active Feb 20, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.