Hi, I am trying to pull multiple comps for a specific property using Zillow API's. However, there are multiple comps in the XML file associated with the specific property, and my code keeps pulling the same 2 or 3 property data from the URL, how should it be coded it to move onto the next <comps>? Any help would be appreciated.
Here is an example XML file:
http://www.zillow.com/webservice/Get...33642&count=20
And corresponding code I'm using, which has been copied and edited from some other users on this site:
URL = "http://www.zillow.com/webservice/GetDeepComps.htm?zws-id=" & ZWSID & "&zpid=" & rowZpid & "&count=" & Count
'Open XML page
Set xmldoc = New MSXML2.DOMDocument60
xmldoc.async = False
' Check XML document is loaded
If xmldoc.Load(URL) Then
Set xmlMessage = xmldoc.SelectSingleNode("//message/text")
Set xmlMessageCode = xmldoc.SelectSingleNode("//message/code")
' Check for an error message
If xmlMessageCode.Text <> 0 Then
' Return error message
WS.Range(ErrorMessage & I) = xmlMessage.Text
Else
' Get XML data from Zillow
Set xmlHomeDetails = xmldoc.SelectSingleNode("//response/properties/comparables/comp/links/homedetails")
' Push data to spreadsheet
If xmlHomeDetails Is Nothing Then
WS.Range(HomeDetails & I) = "No home details available"
Else
WS.Range(HomeDetails & I).Formula = "=HYPERLINK(""" & xmlHomeDetails.Text & """,""Zillow Details"")"
End If
' Retrieve Street address, ZIP code ,City
Set xmlStreetAddress = xmldoc.SelectSingleNode("//response/properties/comparables/comp/address/street")
Set xmlZipCode = xmldoc.SelectSingleNode("//response/properties/comparables/comp/address/zipcode")
Set xmlCity2 = xmldoc.SelectSingleNode("//response/properties/comparables/comp/address/city")
' Push data to spreadsheet
If xmlStreetAddress Is Nothing Then
WS.Range(StreetAddress & I) = "N/A"
Else
WS.Range(StreetAddress & I) = xmlStreetAddress.Text
End If
If xmlZipCode Is Nothing Then
WS.Range(ZipCode & I) = "N/A"
Else
WS.Range(ZipCode & I) = xmlZipCode.Text
End If
If xmlCity2 Is Nothing Then
WS.Range(City2 & I) = "N/A"
Else
WS.Range(City2 & I) = xmlCity2.Text
End If
' Retrieve Beds & Baths
Set xmlBed = xmldoc.SelectSingleNode("//response/properties/comparables/comp/bedrooms")
Set xmlBath = xmldoc.SelectSingleNode("//response/properties/comparables/comp/bathrooms")
' Push data to spreadsheet
If xmlBed Is Nothing Then
WS.Range(Bed & I) = "N/A"
Else
WS.Range(Bed & I) = xmlBed.Text
End If
If xmlBath Is Nothing Then
WS.Range(Bath & I) = "N/A"
Else
WS.Range(Bath & I) = xmlBath.Text
End If
Bookmarks