PHP HTML DOM Parser [duplicate]

╄→гoц情女王★ 提交于 2019-11-27 22:10:52

问题


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?


回答1:


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.




回答2:


You can look at the builtin DOM

http://php.net/dom




回答3:


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



来源:https://stackoverflow.com/questions/4330545/php-html-dom-parser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!