Friday, January 26, 2018

PHP HTML DOM Parser











I'm looking into HTML DOM parsers for PHP. I've found PHP Simple HTML DOM Parser. Are there any others I should be looking at?


Answer



Yes. Simple html doc is fine, but an order of magnitude slower than the built in dom parser.



$dom = new DOMDocument();
@$dom->loadHTML($html);

$x = new DOMXPath($dom);

foreach($x->query("//a") as $node)
{
$data['dom']['href'][] = $node->getAttribute("href");
}


Use that.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...