1
votes

I know that I can get an XML file returning geographic information from this URL, by replacing [A] and [B] with latitude and longitude.

http://maps.googleapis.com/maps/api/geocode/xml?latlng=[A],[B]&sensor=true

Now what I want to know is how to call this URL from my .xqy file and simply get the values of the address and town attributes in the XML file. Any idea ?

2
Is your question really, "How do I parse an XML file and extract values?"Steve Wellens
That's what I want to know yeah.Rob

2 Answers

2
votes

You can use the expath HTTP client in order to query this API:

import module namespace http = "http://expath.org/ns/http-client";

http:send-request(<http:request method="get" href="http://maps.googleapis.com/maps/api/geocode/xml?latlng=[A],[B]&amp;sensor=true" />)

You can try this example live at http://www.zorba-xquery.com/html/demo#SYTRRzV6oopDKuEs3hxUdj4lUts=