脚本宝典收集整理的这篇文章主要介绍了PHP解析无效的html,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$dom = new DOMDocument(); $dom->loadhtmlfile("http://www.some-sITe.org/page.aspx"); echo $dom->getElementById('his_id')->item(0);
但是PHP会返回一个类似ID his_id的错误,这个错误已经在http://www.some-site.org/page.aspx中定义,第33行.我认为这是因为DOMDocument正在处理无效的htML.那么,即使无效,我怎么解析呢?
$html = file_get_contents('http://www.some-site.org/page.aspx'); $config = array( 'clean' => 'yes','output-html' => 'yes',); $tidy = tidy_parse_string($html,$config,'utf8'); $tidy->cleanRepair(); $dom = new DOMDocument; $dom->loadHTML($tidy);
以上是脚本宝典为你收集整理的PHP解析无效的html全部内容,希望文章能够帮你解决PHP解析无效的html所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。