-1
//android.widget.TextView[contains(@text,'South Korea's')] 

doesn't work, gives below parsing error

org.eclipse.wst.xml.xpath2.processor.XPathParserException: CUP parser error: Parser error: line 1 col 55: s

However //android.widget.TextView[contains(@text,'South Korea')] works, when I remove 's from 'South Korea's'

How to handle this issue?

JaSON
  • 4,843
  • 2
  • 8
  • 15
  • Does this answer your question? [Escape single quote in XPath with Nokogiri?](https://stackoverflow.com/questions/14822153/escape-single-quote-in-xpath-with-nokogiri) – JaSON Jun 23 '23 at 13:11

1 Answers1

0

As you seem to use an XPath 2.0 implementation, the notation described in https://www.w3.org/TR/xpath20/#id-literals to double single or double quotes in XPath string literals should work e.g. @text,'South Korea''s'). Of course double quote as delimiters e.g. @text,"South Korea's") should also do, just make sure you do any encoding the host language (e.g. Java) requires for the double quotes if the XPath expression is a string in that host language.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110