示例#1
0
 protected static function _xpathOrCss2Xpath($exp)
 {
     if (preg_match('/^id\\(/', $exp)) {
         return preg_replace("/^id\\(((?:'|\")(\\w*)(?:'|\"))\\)/", '//*[@id=$1]', $exp);
     } else {
         if (preg_match('#^(?:\\.$|\\./)#', $exp)) {
             return $exp;
         } else {
             if (preg_match('!^/!', $exp)) {
                 return '.' . $exp;
             } else {
                 if (ctype_alnum($exp)) {
                     return ".//{$exp}";
                 } else {
                     return '.' . preg_replace('#//+#', '//', str_replace(chr(32), '', Css2Xpath::transform($exp)));
                 }
             }
         }
     }
 }
示例#2
0
 /**
  * Perform a CSS selector query
  *
  * @param  string $query
  * @return NodeList
  */
 public function execute($query)
 {
     $xpathQuery = Css2Xpath::transform($query);
     return $this->queryXpath($xpathQuery, $query);
 }
示例#3
0
 /**
  * @group ZF-9764
  */
 public function testIdSelectorWithLeadingAsterix()
 {
     $test = Css2Xpath::transform('*#id');
     $this->assertEquals("//*[@id='id']", $test);
 }