Created
August 21, 2011 23:49
-
-
Save iaindooley/1161355 to your computer and use it in GitHub Desktop.
xpathEscape() inputs and expected output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('xpath_escape.php'); | |
$strings = array('i think therefore i am', | |
'the pimp\'s "main squeeze" was talkin\' jive'); | |
foreach($strings as $query) | |
echo xpathEscape($query).PHP_EOL; | |
/** | |
* EXPECTED OUTPUT: | |
* "i think therefore i am" | |
* concat('the pimp',"'",'s ','"','main squeeze','"',' was talkin',"'",' jive') | |
* | |
* EXAMPLE USAGE | |
* $xml->xpath('//node[subnode='.xpathEscape($string).']'); | |
* | |
* NOTE: because if no single or double quotes are present the original query is returned | |
* wrapped in the delimeter (default " but you can pass it in as an optional argument | |
* to xpathEscape()) you do not include string delimeters in the xpath expression when | |
* calling the escape function | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment