Esempio n. 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)));
                 }
             }
         }
     }
 }
Esempio n. 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);
 }
Esempio n. 3
0
 /**
  * @group ZF-9764
  */
 public function testIdSelectorWithLeadingAsterix()
 {
     $test = Css2Xpath::transform('*#id');
     $this->assertEquals("//*[@id='id']", $test);
 }