예제 #1
0
파일: Crawler.php 프로젝트: romankd/symfony
 /**
  * Filters the list of nodes with a CSS selector.
  *
  * This method only works if you have installed the CssSelector Symfony Component.
  *
  * @param string $selector A CSS selector
  *
  * @return Crawler A new instance of Crawler with the filtered list of nodes
  *
  * @throws \RuntimeException if the CssSelector Component is not available
  */
 public function filter($selector)
 {
     if (!class_exists('Symfony\\Component\\CssSelector\\Converter')) {
         throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector 2.8+ is not installed (you can use filterXPath instead).');
     }
     $converter = new Converter($this->isHtml);
     // The CssSelector already prefixes the selector with descendant-or-self::
     return $this->filterRelativeXPath($converter->toXPath($selector));
 }
예제 #2
0
 public function testCssToXPathXml()
 {
     $converter = new Converter(false);
     $this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1'));
 }