#33 Dinamic class for DOM nodes

Next_Release
open
nobody
None
1
2012-10-28
2012-10-28
aVadim
No

Thanx for your script! I searched PHP parser without any external PHP-extensions (like libxml). But I need extend your classes. And I do it by this way:

1) I added additional properti for simple_html_dom class:

public $dom_node_class = 'simple_html_dom_node';

2) In class simple_html_dom I found text

new simple_html_dom_node(...);

and replaced it by

new $this->dom_node_class(...);

3) And now I can use my own extended classes:

class MyNode extends simple_html_dom_node {

}

class MyDom extends simple_html_dom {

public function __construct(...) {

$this->dom_node_class = 'MyNode';

parent::__construct(...);

}

}

So we can extend default classes without touching original source code. I hope you'll like my idea and you'll use it in your new releases

Discussion