Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP HTML DOM Parser [duplicate]

Possible Duplicate:
How to parse and process HTML with PHP?

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?

like image 207
StackOverflowNewbie Avatar asked Dec 02 '10 00:12

StackOverflowNewbie


3 Answers

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.

like image 118
Byron Whitlock Avatar answered Nov 02 '22 15:11

Byron Whitlock


You can look at the builtin DOM

http://php.net/dom

like image 20
KingCrunch Avatar answered Nov 02 '22 17:11

KingCrunch


Recently I also found ganon, but in general PHP Simple HTML DOM Parser is the best!

like image 24
Slav Avatar answered Nov 02 '22 15:11

Slav