-1

importxml is working fine with manual insert but while updating with funtions getting syntax error. Kindly help me.. how to convert string to actual query.

function Getdata() { 

var Technicals = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Techinical"); var queryString = Math.random();

var oilindicators='=IMPORTXML("http://www.investing.com/commodities/crude-oil-technical","//*[@id='last_last']")'; Technicals.getRange('a1').setValue(oilindicators);

}

1

How about this modification?

Modification points :

  • Please escape single quotes in IMPORTXML().
  • When the formula is imported, please use setFormula().

From :

var oilindicators='=IMPORTXML("http://www.investing.com/commodities/crude-oil-technical","//*[@id='last_last']")';
Technicals.getRange('a1').setValue(oilindicators);

To :

var oilindicators = '=IMPORTXML("http://www.investing.com/commodities/crude-oil-technical","//*[@id=\'last_last\']")'; // Modification
Technicals.getRange('a1').setFormula(oilindicators); // Modification

Reference :

  • The above query worked for me. I one more help is it possible to covert the xml import cell to text not with xml formulas. – Murali Pujari Mar 8 '18 at 10:26
  • @Murali Pujari I'm sorry. For your next question, I couldn't understand what you want to do. So can you post it with the detail information and samples as a new question? By this, many users including me can think of your solution. If my this proposal is what you don't want, I apologize. – Tanaike Mar 8 '18 at 23:30
  • Thanks for reply, I need to know who to change the xml fetch data to text that means content only--- should not be formulas only the text – Murali Pujari Mar 9 '18 at 10:45
  • Sorry Tanaike, I have posted question. webapps.stackexchange.com/questions/115231/… – Murali Pujari Mar 9 '18 at 11:20
  • @Murali Pujari Thank you for your response. – Tanaike Mar 9 '18 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.