From: Faith Greenwood on
I am trying to escape single and double quotation marks in an XPATH
expression. Failing to escape the quotes produces an "Invalid
predicate" error.

Here's an example:

my $value="Dave's";
$value =~s/\'/\\\'/g;
my $search="//entry/owner/person[value/text()='$value']/../../this/
animal/value/text()";

However, this also produces the "Invalid predicate" error. I've tried
what the xpath language suggests by replacing a ' with '

my $value="Dave's";
$value =~s/\'/'/g;
my $search="//entry/owner/person[value/text()='$value']/../../this/
animal/value/text()";

This time, though, the search produces no results. (I know the
expression itself is valid as it works on $values that contain no
single or double quotes).

What is the correct way to escape quotation characters for XPath
expressions in perl?