I m using R and the xpathSApply function to get elements from a web page that contains specific strings. I m trying to use the contains function from xpath with several elements I stored in a list called my_list.
my_list <- c("word1", "word2", "word3")
xpathSApply(doc, "//h2[contains(text(),'paste(my_list, collapse='|')')]")
For now it doesn't work, so I divided it into several lines:
xpathSApply(doc, "//h2[contains(text(),'word1')]")
xpathSApply(doc, "//h2[contains(text(),'word2')]")
xpathSApply(doc, "//h2[contains(text(),'word3')]")
Can you please help me?