Skip to content

Instantly share code, notes, and snippets.

@renatoliveira
Created October 13, 2016 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renatoliveira/2aa37a3ea302b4792c58489540edfbd0 to your computer and use it in GitHub Desktop.
Save renatoliveira/2aa37a3ea302b4792c58489540edfbd0 to your computer and use it in GitHub Desktop.
Simple script to get a XML from a service and translate it to JSON
import requests
from json import dumps
from xmljson import parker as pk
from xml.etree.ElementTree import fromstring
endpoint = 'http://webserviceurlhere/number'
xml = requests.get(endpoint).text
result = dumps(pk.data(fromstring(xml)))
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment