note 91901 added to domdocument.load

From: Date: Wed, 01 Jul 2009 06:28:34 +0000
Subject: note 91901 added to domdocument.load
Groups: php.notes 
Request: Send a blank email to php-notes+get-157744@lists.php.net to get a copy of this message
You can easily avoid the warning about &nbsp; references by using the LIBXML_DTDLOAD option. <?php $html = <<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <p>&nbsp;</p> </body> </html> EOF; // This one works perfectly. $dom = new DOMDocument(); $dom->loadXML($html, LIBXML_DTDLOAD); print $dom->saveXML(); // This one produces a warning. $dom = new DOMDocument(); $dom->loadXML($html); print $dom->saveXML(); ?> See also: http://www.php.net/manual/en/libxml.constants.php Note that libxml will detect that your DTD is locally available via /etc/xml/catalog. So there is no worry about this causing your DOM loads to make external network requests. ---- Server IP: 64.71.164.2 Probable Submitter: 203.134.28.230 ---- Manual Page -- http://www.php.net/manual/en/domdocument.load.php Edit -- https://master.php.net/note/edit/91901 Del: integrated -- https://master.php.net/note/delete/91901/integrated Del: useless -- https://master.php.net/note/delete/91901/useless Del: bad code -- https://master.php.net/note/delete/91901/bad+code Del: spam -- https://master.php.net/note/delete/91901/spam Del: non-english -- https://master.php.net/note/delete/91901/non-english Del: in docs -- https://master.php.net/note/delete/91901/in+docs Del: other reasons-- https://master.php.net/note/delete/91901 Reject -- https://master.php.net/note/reject/91901 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157744) next »