MJ
asked on
JavaScript - How to pass a single quote to a document.evaluate?
I'm getting the following error ncaught DOMException: Failed to execute 'evaluate' on 'Document': The string '//div[contains(., 'Please tell us how much you'd like to put into your account,')]' is not a valid XPath expression. for this line:
var sec3 = document.evaluate("//div[contains(., 'Please tell us how much you\'d like to put into your account,')]", document, null, XPathResult.ANY_TYPE, null).iterateNext();
If I remove the single quote from the string I'm looking for, the error goes away. I tried escaping the single quote and URL encoding it and it still breaks. How do I keep the single quote in the string?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome.
ASKER