Similar to How to deal with single quote in xpath, I want to escape single quotes. The difference is that I can\'t exclude the possibility that a double quote might also app
Because you are using string manipulation to build your XPath expression, it's your responsibility that the expression is valid XPath. This expression:
//*[contains(.,concat('Fat"',"her's son"))]
Selects:
Fat"her's son
Test in here
It would be a better approach to use an XPath string variable, but it looks like R doesn't have an API for that, even using libxml.