Here is my code:
Code: Select all
class ParseHTML {
var $parser;
var $links;
function ParseHTML() {
$this->parser = &new XML_HTMLSax();
$this->parser->set_object($this);
$this->parser->set_element_handler('open', 'close');
$this->parser->set_data_handler('data');
$this->links = array();
}
function open($parser, $tag, $attr) {
if($tag == "a") {
if(count($attr) > 0) {
$hashed_link = md5($attr['href']);
$this->links[$hashed_link] = $attr['href'];
}
}
}
function close($parser, $tag) {
}
function parse($html) {
$this->parser->parse($html);
return $this->links;
}
}Thanks in advance.