import xml.etree.ElementTree as et import urllib.request #Reading from a file: #filename = "KFTY.xml" #tree = et.parse(filename) #Reading from the web directly: response = urllib.request.urlopen("http://www.weather.gov/data/current_obs/KFTY.xml") tree = et.parse(response) root = tree.getroot() tempF = root.find("temp_f") #Read the tag text: tempText = tempF.text tempFloat = float(tempText) #Read the root nodes version attribute. xmlVersion = root.attrib['version'] img = root.find("image") u = img.find("url") printStr = "The current Temp is: {}".format(tempFloat) printStr2 = "The xml version is: {}".format(xmlVersion) printStr3 = "The weather image is at: {}".format( u.text) print(printStr) print(printStr2) print(printStr3)