Trouble Parsing XML in Python with xml.doc.minidom



I am trying to get the lot size of a house from Zillow's API, but I am not printing out the correct result.


My goal is to print out the value in the XML field of "lotSizeSqFt". Whenever I print, all I get is empty square brackets. Anybody know what's going on?



from bs4 import BeautifulSoup
import requests
import urllib, urllib2
import csv

from xml.dom import minidom
import xml.dom.minidom

#makes an api call for a given address
def makeCall(address, cityStateZip):
url = "http://ift.tt/1vbYL2F" + address + "&citystatezip=" + cityStateZip

#parse the XML document
xml = urllib2.urlopen(url)
xmldoc = minidom.parse(xml)

return xmldoc



def getData(address, cityStateZip):

#returns parsed XML doc
xmldoc = makeCall(address, cityStateZip)

#get necesary data
lotsize = xmldoc.getElementsByTagName("lotSizeSqFt")

return lotsize


address = "10608 Floral Park Lane"
cityStateZip = "North Potomac, MD 20878"

print getData(address, cityStateZip)

No comments:

Post a Comment