Hi All,
Please help me out with this code snippet. I am here in trouble with "SelectNodes". Whenever I am using "SelectSingleNode", the code is fetching me results but when I am using SelectNodes in place of SelectSingleNode the code is throwing me 0 (nothing). Please suggest what to do.
I am new to VBA and have written this code with lots of googling about syntaxes and datatypes. Please correct if anywhere wrong and tell me what I am missing.
Function UserPlaces(Origin As String) As String Dim himRequest As XMLHTTP60 Dim himDomDoc As DOMDocument60 Dim nodeList As IXMLDOMNode UserPlaces = 0 On Error GoTo exitRoute Origin = Replace(Origin, " ", "%20") Set himRequest = New XMLHTTP60 himRequest.Open "GET", "https://maps.googleapis.com/maps/api/place/nearbysearch/xml?location=" _ & Origin & "&radius=5000&types=food&sensor=false&key=YOUR KEY HERE", False himRequest.send Set himDomDoc = New DOMDocument60 himDomDoc.LoadXML himRequest.responseText Set nodeList = himDomDoc.SelectSingleNode("//result/vicinity") If Not nodeList Is Nothing Then UserPlaces = nodeList.Text exitRoute: Set nodeList = Nothing Set himDomDoc = Nothing Set himRequest = Nothing End Function