0
votes

So I'm trying a test, trying to see if I can import an options price from Yahoo Finance into a google spreadsheet.

Here is the formula I'm trying to execute: =ImportXML("http://finance.yahoo.com/q?s=NGG120616P00040000","//*[@id="yfs_L10_ngg120616p00040000"]")

Is anyone familiar with how importXML works and in my case, what the proper xpath expression would be to query this data?

Cheers

2
What result are you getting from the XPath you're trying to use? How do you know that result is wrong? Or rather, what did you want instead? - LarsH

2 Answers

2
votes

There are two problems: 1) case in the attribute value matters, so you need a lowercase l in yfs_l10_ngg120616p00040000 instead of yfs_L10_ngg120616p00040000; 2) as @LarsH points out you also need to make sure you don't nest double-quotes inside of double quotes. So, here's the expression that will work:

=ImportXML("http://finance.yahoo.com/q?s=NGG120616P00040000", "//*[@id='yfs_l10_ngg120616p00040000']")

In this example it yields the values:

0.45
0.45
0
votes

It would be best if you tell what results you are getting. An error? An empty string? Some other string or number? And also show a sample of the XML (HTML) you're trying to apply the XPath to, rather than expect us to go look it up; and specify what node(s) you're trying to select, rather than leaving us to infer it from a fairly vague description.

However, one thing that's probably wrong is the use of double quotes within double quotes. If you change the inner quotes to apostrophes, that will help:

ImportXML("http://finance.yahoo.com/q?s=NGG120616P00040000",
          "//*[@id='yfs_L10_ngg120616p00040000']")