Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除DOM警告PHP_Php_Dom - Fatal编程技术网

删除DOM警告PHP

删除DOM警告PHP,php,dom,Php,Dom,我有以下代码: $strhtml = file_get_contents('05001400300320100033100.html'); $dochtml = new DOMDocument(); $dochtml->loadHTML($strhtml); $elm = $dochtml->getElementById('upPanelActuciones'); print $dochtml->saveXml($elm); 我收到这个警告: Warning

我有以下代码:

$strhtml = file_get_contents('05001400300320100033100.html');
$dochtml = new DOMDocument();
 $dochtml->loadHTML($strhtml);
 $elm = $dochtml->getElementById('upPanelActuciones');
 print $dochtml->saveXml($elm);
我收到这个警告:

      Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: error parsing attribute  name in Entity, line: 674 in C:\AppServ\www\video01\sector2\dom3.php on line 10

      Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Opening and ending tag mismatch: div and td in Entity, line: 1019 in C:\AppServ\www\video01\sector2\dom3.php on line 10

      Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Opening and ending tag mismatch: div and td in Entity, line: 1020 in C:\AppServ\www\video01\sector2\dom3.php on line 10

      Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Opening and ending tag mismatch: div and td in Entity, line: 1022 in C:\AppServ\www\video01\sector2\dom3.php on line 10
我无法操作html(我知道html文件有错误),所以有办法删除此警告吗?(没有演出)

提前感谢你的帮助

DOMDocument非常擅长处理不完美的标记,但是 当它这样做的时候,到处都是警告

这里没有很好的记录。解决这个问题的办法是实施 处理这些错误的一个单独的平台

在调用loadHTML之前设置libxml\u use\u internal\u errors(true)。这 将防止错误冒泡到默认错误处理程序。 然后,您可以使用其他libxml错误获取它们(如果您愿意) 功能

你可以在这里找到更多信息

处理DOMDocument错误的正确方法是:

<?php

// enable user error handling
var_dump(libxml_use_internal_errors(true));

// load the document
$doc = new DOMDocument;

if (!$doc->load('file.xml')) {
    foreach (libxml_get_errors() as $error) {
        // handle errors here
    }

    libxml_clear_errors();
}

?>
load('file.xml')){
foreach(libxml_get_errors()作为$error){
//在这里处理错误
}
libxml_clear_errors();
}
?>