Doc #60747 [NEW]: DOMDocument loadHTML error with img close tag

From: Date: Fri, 13 Jan 2012 16:18:18 +0000
Subject: Doc #60747 [NEW]: DOMDocument loadHTML error with img close tag
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7778@lists.php.net to get a copy of this message
From: Operating system: PHP version: 5.3.9 Package: DOM XML related Bug Type: Documentation Problem Bug description:DOMDocument loadHTML error with img close tag Description: ------------ --- From manual page: http://www.php.net/domdocument.loadhtml --- It says that this function should handle input that is not well-formed without error. However, I have tried to parse a page (that I don't have control over) and found it will throw errors. I have found that this can be avoided with: libxml_use_internal_errors(true). If I remove the first line of the example below, I just get an error page, which I wouldn't expect from reading the documentation. I feel that this should be more clear in the documentation, but I'm assuming it's not a bug by itself. Test script: --------------- <?php libxml_use_internal_errors(true); $document->loadHTML( '<img src="a.png" alt="a"></img>' ); foreach ( libxml_get_errors() as $error ) { var_dump( $error ); } $imgs = $document->getElementsByTagName( 'img' ); var_dump( $imgs ); ?> Expected result: ---------------- object(DOMNodeList)[3] Actual result: -------------- object(LibXMLError)[2] public 'level' => int 2 public 'code' => int 76 public 'column' => int 32 public 'message' => string 'Unexpected end tag : img ' (length=25) public 'file' => string '' (length=0) public 'line' => int 1 object(DOMNodeList)[3] -- Edit bug report at https://bugs.php.net/bug.php?id=60747&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60747&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60747&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60747&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60747&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60747&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60747&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60747&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60747&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60747&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60747&r=support Expected behavior: https://bugs.php.net/fix.php?id=60747&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60747&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60747&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60747&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60747&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60747&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60747&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60747&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60747&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60747&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60747&r=mysqlcfg

« previous php.doc.bugs (#7778) next »