simplifyXpath($xpathSubject); $pathPattern = '#^' . $pathPattern . '$#'; return (bool)preg_match($pathPattern, $pathSubject); } /** * Strip off predicates and namespaces from the XPath * * @param string $xpath * @return string */ protected function simplifyXpath($xpath) { $result = $xpath; $result = preg_replace('/\[@[^\]]+?\]/', '', $result); $result = preg_replace('/\/[^:]+?\:/', '/', $result); return $result; } }