How to write an XML code to get a particular data from google finance? What am I doing wrong?

46 Views Asked by At

https://www.google.com/finance/quote/TSLA:NASDAQ

This is where I am trying to get the code. I am trying to get the Net Income Field which for Tesla is 1.85B.

BTW I am trying to get the data in a google sheet.

enter image description here

I am using this:

=IMPORTXML("https://www.google.com/finance/quote/TSLA:NASDAQ","//table[contains(@class, 'slpEwd')]//tr[contains(@class,'roXhBd')]//td[contains(@class,'QXDnM')]")

But it returns all the values in the column. I just want that 1 value. What needs to change?

Any help will be appreciated.

1

There are 1 best solutions below

0
rockinfreakshow On

Here's one approach you may test out:

=let(Σ,importhtml(A2,"table",1),
     filter(index(Σ,,2),left(index(Σ,,1),10)="Net income"))

enter image description here