예제 #1
0
 public function testWhitewashingHeaders()
 {
     $parser = new PHPricot_Parser();
     $doc = $parser->parse(file_get_contents(dirname(__FILE__) . "/_files/whitewashing.html"));
     $cssHandler = new PHPricot_CssParser_EventHandler($doc);
     $cssParser = new CssParser('div.box h2', $cssHandler);
     $cssParser->parse();
     $headers = $cssHandler->getMatches();
     $this->assertEquals(10, count($headers), "Whitewashing Main Page example should have 10 h2 tags");
 }
예제 #2
0
파일: Query.php 프로젝트: beberlei/phpricot
 public function __construct($input)
 {
     if (is_string($input)) {
         $parser = new PHPricot_Parser();
         $doc = $parser->parse($input);
     } else {
         if ($input instanceof PHPricot_Document) {
             $doc = $input;
         } else {
             if ($input instanceof PHPricot_Nodes_Node) {
                 $doc = new PHPricot_Document();
                 $doc->childNodes[] = $input;
             } else {
                 if (is_array($input)) {
                     $doc = new PHPricot_Document();
                     $doc->childNodes = $input;
                 } else {
                     throw new InvalidArgumentException('PHPricot_Query expects an HTML string as argument.');
                 }
             }
         }
     }
     $this->doc = $doc;
 }