XPath simple conditional statement? If node X exists, do Y?
问题 I am using google docs for web scraping. More specifically, I am using the Google Sheets built in IMPORTXML function in which I use XPath to select nodes to scrape data from. What I am trying to do is basically check if a particular node exists, if YES, select some other random node. /*IF THIS NODE EXISTS*/ if(exists(//table/tr/td[2]/a/img[@class='special'])){ /*SELECT THIS NODE*/ //table/tr/td[2]/a } 回答1: You don't have logic quite like that in XPath, but you might be able to do something