Search code examples
google-sheets-formula

Can't get NAV value using importXML


I would like to have some help to get the NAV data from this link using importxml / xpath. https://www.vanguardinvestments.com.au/retail/ret/investments/product.html#/fundDetail/wholesale/portId=8125/?prices ... so in this case the NAV data is $1.3446 . I would like to get this value using importxml / xpath.

How to do that? I've tried some formulas but.. not able to get the details from the website.

=(IMPORTXML("https://www.vanguardinvestments.com.au/retail/ret/investments/product.html#/fundDetail/wholesale/portId=8125/?prices","//td[@class='ng-binding']"))

Solution

  • I believe that the issue in getting the value is that if you check the webpage source code [e.g. in Chrome right click -> View Page Source] that number is not directly available there

    As outlined in this other answer:

    IMPORTXML can not retrieve data which is populated by a script, and so using this formula to retrieve data from this table is not possible to do

    This is why if you try to run it with its element xpath:

    =IMPORTXML(A1,"//*[@id='tab-container']/div[2]/detail-prices-full/div/table[2]/tbody/tr[1]/td[2]")
    

    you get empty content

    The fact that the element is provided via a script can be confirmed by testing as suggested here, opening the developer tools of your browser and disabling JavaScript [e.g. in Chrome]

    Without closing the developer tools, if you reload the website in this condition you'll see this:

    Website with JS disabled

    so you won't be able to get it via IMPORTXML