How to select element that contains single quotes using XPath?
问题 I would like to select this element using XPath : <a href="#" onClick="onViewDocument('2016', '1');">2016</a> So far I have this: //a[@onClick='onViewDocument('2016', '1');'] Do I need to escape the single quotes around the 2016 and 1 ? 回答1: Simplest usually is to use the alternative of ' or " , depending upon what was already used surrounding the string literal. If that's not feasible, an alternative is to use ' for ' ( single quote ): //a[@onClick='onViewDocument('2016',