WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

MSXML

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Geolocate

 Keywords: MSXML LoadXML SelectNodes Parse XML

;Winbatch 2011B - Simple IP/Geolocate test
;  returns text, text added to 2nd URL to return XML
;
;Stan Littlefield, April 25, 2013
;Deana Falk, April 25, 2013
;////////////////////////////////////////////////////////////////////////////////////////


cURL='http://myip.dnsomatic.com'
oHTTP = ObjectCreate("WinHttp.WinHttpRequest.5.1")
oHTTP.Open("GET", cURL, @FALSE)
oHTTP.send()
oHTTP.WaitForResponse()

cIP=oHTTP.ResponseText  ;should return your public IP address
cURL="http://freegeoip.net/xml/%cIP%"

oHTTP.Open("GET", cURL, @FALSE)
oHTTP.send()
oHTTP.WaitForResponse()

xmldata = oHTTP.ResponseText

; Parse XML
oXML = ObjectCreate("MSXML.DOMDocument")
oXML.Async = @FALSE
;oXML.Namespaces = @False
Loaded = oXML.LoadXML(xmldata)

If !Loaded Then
  Display(1,"Warning","The service is not available.")
  Goto Cleanup
EndIf

Ip = oXML.SelectNodes("//Ip").Item(0).text
CountryCode = oXML.SelectNodes("//CountryCode").Item(0).text
CountryName = oXML.SelectNodes("//CountryName").Item(0).text
RegionCode = oXML.SelectNodes("//RegionCode").Item(0).text

data = "IP ":IP:@LF:"CountryCode ":CountryCode:@LF:"CountryName ":CountryName:@LF:"RegionCode ":RegionCode:@LF
Message("",data)

:CleanUP
oHTTP = 0
oXML=0
Exit
;////////////////////////////////////////////////////////////////////////////////////

Article ID:   W18498
Filename:   Geolocate.txt
File Created: 2013:04:25:11:38:32
Last Updated: 2013:04:25:11:38:32