コード例 #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
ファイル: ConverterTest.php プロジェクト: romankd/symfony
 public function testCssToXPathXml()
 {
     $converter = new Converter(false);
     $this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1'));
 }