Link to home
Start Free TrialLog in
Avatar of dabug80
dabug80

asked on

World Bank Data API: Converting links to data?

Hello,

The World Bank website currently allows anyone to use it's worldwide data

In the above page, the World bank provides a basic call structure format. Following this protocol, I have generated links such as:
Surface area (sq. km) of Ethiopia: http://api.worldbank.org/countries/ETH/indicators/AG.SRF.TOTL.K2?MRV=1&Gapfill=Y

Entering the above link into a url, returns the following data:

<wb:data xmlns:wb="http://www.worldbank.org" page="1" pages="1" per_page="50" total="1">
<wb:data>
<wb:indicator id="AG.SRF.TOTL.K2">Surface area (sq. km)</wb:indicator>
<wb:country id="ET">Ethiopia</wb:country>
<wb:date>2014</wb:date>
<wb:value>1104300</wb:value>
<wb:decimal>0</wb:decimal>
</wb:data>
</wb:data>

Open in new window


I'm not a programmer, but all I want to be able to do is grab the <wb:value> of 1104300 above and add it to a webpage, for multiple url links.

E.g my website would have 10 separate pages (one for each country) and on each of these pages would be the label: Surface area (sq. km): alongside the pulled World Bank data from the above url.

How would I approach this?
Avatar of Shalom Carmel
Shalom Carmel
Flag of Israel image

I didn't know that about the world bank :)

You need some code and programming to extract the value from the XML. Which language do your programmers use, or which language is used on you web site?

There are 2 general approaches:
* Do it on the server. If your web site uses ruby code, then the logic of retrieving the links, parsing the XML and displaying it in context, will be written in ruby.

* Do it on the client. You will write Javascript code that runs in the browser to retrieve the links, parse the XML and display it in context.
Just checked - you can't do it client-side in Javascript, because the CORS headers are missing on the World Bank API :(
ASKER CERTIFIED SOLUTION
Avatar of Shalom Carmel
Shalom Carmel
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dabug80
dabug80

ASKER

Excellent. Thanks for taking the time to code and explain. Really appreciate it.