parse() public method

Runs the content through the lexer which should call back to the acceptors.
public parse ( string $raw ) : boolean
$raw string Page text to parse.
return boolean False if parse error.
 /**
  *    Reads the raw content and send events
  *    into the page to be built.
  *    @param $response SimpleHttpResponse  Fetched response.
  *    @return SimplePage                   Newly parsed page.
  *    @access public
  */
 function parse($response)
 {
     $this->tags = array();
     $this->page = $this->createPage($response);
     $parser = new SimpleHtmlSaxParser($this);
     $parser->parse($response->getContent());
     $this->acceptPageEnd();
     $page = $this->page;
     $this->free();
     return $page;
 }
Beispiel #2
0
 function testNestedFrameInFrameset()
 {
     $listener = $this->createListener();
     $listener->expectAt(0, 'startElement', array('frameset', array()));
     $listener->expectAt(1, 'startElement', array('frame', array('src' => 'frame.html')));
     $listener->expectCallCount('startElement', 2);
     $listener->expectOnce('addContent', array('<noframes>Hello</noframes>'));
     $listener->expectOnce('endElement', array('frameset'));
     $parser = new SimpleHtmlSaxParser($listener);
     $this->assertTrue($parser->parse('<frameset><frame src="frame.html"><noframes>Hello</noframes></frameset>'));
 }