Last active
November 10, 2015 12:48
-
-
Save alxarch/f3c094ae750938585f66 to your computer and use it in GitHub Desktop.
Fetch mnc mcc data from wikipedia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare option output:method "json"; | |
let $page := doc("https://en.wikipedia.org/wiki/Mobile_country_code") | |
return | |
<json type="array"> | |
{ | |
for $h4 in $page//div[@id="bodyContent"]//h4 | |
let $country-code := $h4/span[@id]/text()[last()] | |
let $rows := head($h4/following::table)/tr[td] | |
for $row in $rows | |
return <_ type="object"> | |
<country>{replace($country-code, '.*- (.*)$', '$1')}</country> | |
<mcc>{$row/td[1]/text()}</mcc> | |
<mnc>{$row/td[2]/text()}</mnc> | |
<carrier>{$row/td[3]/data()}</carrier> | |
<company>{$row/td[4]/data()}</company> | |
</_> | |
} | |
</json> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment