I am looking to try and grab Json data from a search specifically from this website: https://koordinates.com/services/query/ ... names=true
this produces a Json data format that I would to grab from this query. Specifically this is the information that I want to grab.
"FeatureCla": "ocean", "Name": "SOUTH ATLANTIC OCEAN", "NameAlt": null (first match)
"FeatureCla": "ocean", "Name": "NORTH ATLANTIC OCEAN", "NameAlt": null (second match)
More than 2 can exits but this example will only contain 2 if you use the link above.
The formats I have tried are by downloading it via ComObjCreate and by UrlDownloadLink. Both seem fairly slow, and I was hoping that I could input several changes to this Json search and get the results from all the inputs.
The following is a working code for the xml format option they give.
Code: Select all
SetBatchLines -1
Lat := -7.9443 , Long := 84.4922
Download := "https://koordinates.com/services/query/v1/vector.xml?key=039b79bb26104e128575d7fcb441de84&layer=1294&x=" Long "&y=" Lat "&max_results=3&radius=10&geometry=true&with_field_names=true"
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", Download, true)
whr.Send()
whr.WaitForResponse()
xmlMaritime := whr.ResponseText
doc := LoadXML(xmlMaritime)
namespace = xmlns:gml="http://www.opengis.net/gml" xmlns:kx="http://api.koordinates.com/schema/vectorQuery/1.1"
doc.setProperty("SelectionNamespaces", namespace)
If (doc.selectSingleNode("//kx:attributes/Name").text = "")
MsgBox No Data
Else
MsgBox % doc.selectSingleNode("//kx:attributes/Name").text
Return
loadXML(ByRef data)
{
o := ComObjCreate("MSXML2.DOMDocument.6.0")
o.async := false
o.loadXML(data)
if (o.parseError.errorCode!=0)
{
msgbox % "can't load dom " o.parseError.reason " on line " o.parseError.line
}
return o
}
Thanks for the help!