From: Faith Greenwood on 24 Jan 2010 12:23 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?
|
Pages: 1 Prev: FAQ 4.46 How do I handle linked lists? Next: print array with separator? |