#39521 [NEW]: DomDocument::createElement() should warn you if you create invalid XML.

From: Date: Wed, 15 Nov 2006 06:04:06 +0000
Subject: #39521 [NEW]: DomDocument::createElement() should warn you if you create invalid XML.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104994@lists.php.net to get a copy of this message
From: daniel dot oconnor at gmail dot com Operating system: Windows PHP version: 5.2.0 PHP Bug Type: DOM XML related Bug description: DomDocument::createElement() should warn you if you create invalid XML. Description: ------------ DomDocument::createElement() should warn you if you create invalid XML. Reproduce code: --------------- <?php $string = '<tree><branch>Fun Games &amp;</branch></tree>'; $xml = new SimpleXMLElement($string); $xml->addChild('actor', 'John & Doe'); print $xml->asXML(); $dom = new domDocument; $dom->loadXML($string); $dom->appendChild($dom->createTextNode("fish &amp; & chips")); $node = $dom->createElement('fish', 'ampersand & this, &amp;'); $dom->appendChild($node); print $dom->saveXML(); Expected result: ---------------- A warning when you do the createElement about the unfinished entity; or at least when you try the saveXML Actual result: -------------- ---------- php ---------- Warning: SimpleXMLElement::addChild(): unterminated entity reference Doe in C:\vx\tests\simplexml.php on line 6 <?xml version="1.0"?> <tree><branch>Fun Games &amp;</branch><actor>John </actor></tree> <?xml version="1.0"?> <tree><branch>Fun Games &amp;</branch></tree> fish &amp;amp; &amp; chips <fish>ampersand & this, &amp;</fish> -- Edit bug report at http://bugs.php.net/?id=39521&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39521&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39521&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39521&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39521&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39521&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39521&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39521&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39521&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39521&r=support Expected behavior: http://bugs.php.net/fix.php?id=39521&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39521&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39521&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39521&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39521&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39521&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39521&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39521&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39521&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39521&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39521&r=mysqlcfg

« previous php.bugs (#104994) next »