For XPath escaping use the following method (of course it could be more efficient).
<?php
public function xpathescape($string)
{
$result = 'concat(';
for($i=0, $j=strlen($string); $i<$j; ++$i)
{
if($i > 0)
$result .= ",";
if($string[$i] == '\'')
$result .= "\"".$string[$i]."\"";
else
$result .= '\''.$string[$i].'\'';
}
$result .= ')';
return $result;
}
?>
Use it this way:
<php
$xpath->query('//example[sub='.xpathescape($acomplexstring).']');
?>