Revision: 40270
Updated Code
at February 9, 2011 10:31 by iroybot
Updated Code
$xpath = new DOMXPath($dom); if (method_exists($xpath, "registerPHPFunctions")) { $xpath->registerNamespace("php", "http://php.net/xpath"); $xpath->registerPHPFunctions('strtolower'); $query = "/root/item[contains(@name_es,'$term') or contains(php:functionString('strtolower',@name_es),'$term')]"; } else { // fallback without PHP }
Revision: 40269
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 28, 2011 10:14 by iroybot
Initial Code
$xpath = new DOMXPath($dom); $xpath->registerNamespace("php", "http://php.net/xpath"); $xpath->registerPHPFunctions('strtolower'); $query = "/root/item[contains(@name_es,'$term') or contains(php:functionString('strtolower',@name_es),'$term')]";
Initial URL
Initial Description
I'm using this out of laziness. PHP is slowing things down here, since it's not as close to C as XPath. A better solution would be to have an attribute specifically for search purposes (either in upper or lowercase).
Initial Title
Using PHP in XPath
Initial Tags
php, xml
Initial Language
PHP