Google-sheets – Getting GDP info by using importXML from IMF webpage

google sheetsimportxml

I'm going to get the updated GDP info by using importXML from IMF webpage.
I type in the following in the spreadsheet, but it return "N/A"
Is there anything wrong with my input?

=importxml("http://www.imf.org/external/datamapper/NGDP_RPCH@WEO/OEMDC/ADVEC/WEOWORLD","//*[@id='dm-main']/div[1]/radio-group/div[3]/imf-ranking/radio-group/div[2]/div[2]")

Best Answer

The bot that fetches content for importxml only gets the HTML source of the page, not any dynamic elements inserted in it with JavaScript. You can see what it sees by opening the page and choosing view-source (typically available with right-click). This is the relevant HTML element:

<imf-ranking dataset={parent.state.dataset} indicators={parent.state.indicators} year={parent.year}></imf-ranking>

There is no data here. The attributes like dataset={parent.state.dataset} indicate that the data will be inserted in this element with a script. importxml cannot access it.