From: clynx at succont dot de Operating system: FreeBSD 4.11 PHP version: 5.0.3 PHP Bug Type: DOM XML related Bug description: Fragments witch replaced Nodes are not globaly useable
Description: ------------ DomDocumentFragments witch replaced existing Nodes in a DomDocument is not globaly useable. * Create a DocumentFragment on an existing DomDocument. * Append one (or more) Child to this Fragment * Replace existing Node with this Fragment The Methods DomDocument->saveXML() displays the Document in the right way. When you use getElementsByTagName, XPath, or e.g. the XSL Extension these new Elements are not there. So in the Example the <replacement> will never be useable, only viewable. Reproduce code: --------------- <?php $xmlData = <<<XMLCONTENT <?xml version="1.0" encoding="utf-8"?> <test> <replace /> </test> XMLCONTENT; $dom = new DomDocument; $dom->loadXML( $xmlData ); $fragment = $dom->createDocumentFragment(); $replacement = $dom->createElement( 'replacement' ); $fragment->appendChild( $replacement ); $additionalNode = $dom->createElement( 'additionalNode' ); $fragment->appendChild( $additionalNode ); foreach( $dom->getElementsByTagName( 'replace' ) AS $node ) { $node->parentNode->replaceChild( $fragment, $node ); } echo "replacement tags found: " . $dom->getElementsByTagName( 'replacment' )->length . "\n\n"; echo "xml code used:\n"; echo $dom->saveXML(); ?> Expected result: ---------------- replacement tags found: 0 xml code used: <?xml version="1.0" encoding="utf-8"?> <test> <replacement/><additionalNode/> </test> Actual result: -------------- replacement tags found: 1 xml code used: <?xml version="1.0" encoding="utf-8"?> <test> <replacement/><additionalNode/> </test> -- Edit bug report at http://bugs.php.net/?id=32011&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32011&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32011&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32011&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32011&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32011&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32011&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32011&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32011&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32011&r=support Expected behavior: http://bugs.php.net/fix.php?id=32011&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32011&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32011&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32011&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32011&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32011&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32011&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32011&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32011&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32011&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32011&r=mysqlcfg