Remove DOM Warning PHP -
i have code:
$strhtml = file_get_contents('05001400300320100033100.html'); $dochtml = new domdocument(); $dochtml->loadhtml($strhtml); $elm = $dochtml->getelementbyid('uppanelactuciones'); print $dochtml->savexml($elm);
im getting warning:
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 , ending tag mismatch: div , td in entity, line: 1019 in c:\appserv\www\video01\sector2\dom3.php on line 10 warning: domdocument::loadhtml() [domdocument.loadhtml]: opening , ending tag mismatch: div , td in entity, line: 1020 in c:\appserv\www\video01\sector2\dom3.php on line 10 warning: domdocument::loadhtml() [domdocument.loadhtml]: opening , ending tag mismatch: div , td in entity, line: 1022 in c:\appserv\www\video01\sector2\dom3.php on line 10
i can't manipulate html (i know html file have errors) there way remove warnings? (no show).
thanks in advance help.
domdocument @ dealing imperfect markup, throws warnings on place when does.
this isn't documented here. solution implement separate aparatus dealing these errors.
set libxml_use_internal_errors(true) before calling loadhtml. prevent errors bubbling default error handler. , can @ them (if desire) using other libxml error functions.
you can find more info here http://www.php.net/manual/en/ref.libxml.php
the right way deal domdocument errors this:
<?php // enable user error handling var_dump(libxml_use_internal_errors(true)); // load document $doc = new domdocument; if (!$doc->load('file.xml')) { foreach (libxml_get_errors() $error) { // handle errors here } libxml_clear_errors(); } ?>
php dom
No comments:
Post a Comment