2

I've tried this and other versions to no avail? Can anyone help please?

=IMPORTXML("http://performance.morningstar.com/fund/ratings-risk.action?t=MWTRX", "//*[@id='div_ratings_risk']/table/tbody/tr[4]/td[3]/text()")
Rubén
  • 34,714
  • 9
  • 70
  • 166
rearThing
  • 632
  • 3
  • 9
  • 26
  • 1
    Hi rearThing! This can have not one but multiple reasons: 1. Google is also parsing html documents, but the html might need to be well-formed as well. The document might be not parsable. 2. And Google is probably parsing the source and not the dynamically added content. The div#div_ratings_risk you are referring to in your Xpath is not filled in the source. Please check view-source:http://performance.morningstar.com/fund/ratings-risk.action?t=MWTRX in Chrome browser to see that by yourself. – matths Nov 30 '17 at 16:48
  • 1
    You might also want to check this answer: https://stackoverflow.com/questions/34217955/importxml-imported-content-empty In your case the URL fetched by jQuery to display the table you try to parse is http://performance.morningstar.com/ratrisk/RatingRisk/fund/rating-risk.action?&t=XNAS:MWTRX&region=usa&culture=en-US&cur=&ops=clear&s=0P00001G5L&ep=true&comparisonRemove=null&benchmarkSecId=&benchmarktype= – matths Nov 30 '17 at 16:57

1 Answers1

3

As explained in the comments to your original question, initially the div Element with the id #div_ratings_risk is initially empty and does not consist of a table. So Google spreadsheets is not able to parse content that is not there and yet needs to be loaded first.

enter image description here

The content (table) you try to fetch data from into your google spreadsheet is dynamically loaded using jQuery from another URL. You can get that URL using e.g. the chrome developer tools and filter for XHR request.

enter image description here

If you parse the content directly from that HTML it will work. So you would need to change your formula to that URL and adapt your XPath like so:

=IMPORTXML("http://performance.morningstar.com/ratrisk/RatingRisk/fund/rating-risk.action?&t=XNAS:MWTRX&region=usa&culture=en-US&cur=&ops=clear&s=0P00001G5L&ep=true&comparisonRemove=null&benchmarkSecId=&benchmarktype=", "//table/tbody/tr[4]/td[3]/text()")
matths
  • 760
  • 9
  • 19