Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vanished Questiion 3

Status
Not open for further replies.

strongm

MIS
May 24, 2001
20,149
GB
Er ... where did the GeoNames question go?
 
Code:
[blue]Public Sub QueryGeonamesAPIExample()
    Dim APICall As String
    Dim Query As String

    APICall = "[URL unfurl="true"]http://api.geonames.org/postalCodeSearch"[/URL]
    Query = "?postalcode=00184&country=IT&username=<yourusername>"
    
    With CreateObject("MSXML2.XMLHTTP")
        .open "GET", APICall & Query, False
        .send
        Debug.Print .responseText 'raw XML response
    End With
End Sub[/blue]

GeoNames REST API documented here;
 
ahhhhhh...
now the code return:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<geonames>
<totalResultsCount>1</totalResultsCount>
<code>
<postalcode>00184</postalcode>
<name>Roma</name>
<countryCode>IT</countryCode>
<lat>41.89193</lat>
<lng>12.51133</lng>
<adminCode1 ISO3166-2="62">07</adminCode1>
<adminName1>Lazio</adminName1>
<adminCode2>RM</adminCode2>
<adminName2>Roma</adminName2>
<adminCode3/>
<adminName3/>
</code>
</geonames>

but is possible to store the result into an array, and looping tath line by line, without to print in a txt file?
 

Code:
...
Dim MyArray() As String
Dim x As Integer
...[green]
   'Debug.Print .responseText 'raw XML response[/green]
    MyArray = Split(.responseText, vbNewLine)
    For x = LBound(MyArray) To UBound(MyArray)
        Debug.Print MyArray(x)
    Next x
...


---- Andy

There is a great need for a sarcasm font.
 
If you just want the returned data parsed into separate lines, then Andy has provided that. Is that what you werer asking for? Or do you have some other goal in mind?
 
No tks!
Brilliant solution
Tks strongm and Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top