When I use a function such as =importXml("http://www.google.com", "//a/@href")
in a Google Spreadsheet cell, it works just fine. However, when I try to use the same function in a script, it gives an error message.
My script has the following code:
function myFunction() {
return importXml("http://www.google.com", "//a/@href");
}
When I call the function from a cell by using =myFunction()
, I get the following error:
error: ReferenceError: "importXml" is not defined.
How can I use the importXml
function in a script?