note 85381 added to domxpath.query
| From: | Niklas at osu1 dot php dot net | Date: | Wed, 27 Aug 2008 21:36:18 +0000 |
| Subject: | note 85381 added to domxpath.query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143899@lists.php.net to get a copy of this message | ||
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).']');
?>
----
Server IP: 209.41.74.194
Probable Submitter: 85.214.28.157
----
Manual Page -- http://www.php.net/manual/en/domxpath.query.php
Edit -- https://master.php.net/note/edit/85381
Del: integrated -- https://master.php.net/note/delete/85381/integrated
Del: useless -- https://master.php.net/note/delete/85381/useless
Del: bad code -- https://master.php.net/note/delete/85381/bad+code
Del: spam -- https://master.php.net/note/delete/85381/spam
Del: non-english -- https://master.php.net/note/delete/85381/non-english
Del: in docs -- https://master.php.net/note/delete/85381/in+docs
Del: other reasons-- https://master.php.net/note/delete/85381
Reject -- https://master.php.net/note/reject/85381
Search -- https://master.php.net/manage/user-notes.php