Simultaneously escape double and single quotes in Xpath

前端 未结 4 979
梦谈多话
梦谈多话 2021-01-12 16:57

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

4条回答
  •  感情败类
    2021-01-12 17:24

    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.

提交回复
热议问题