xmlUnlinkNode(oldchild);
newchild = _php_dom_insert_fragment(nodep, prevsib, nextsib, newchild, intern, newchildobj TSRMLS_CC);
- dom_reconcile_ns(nodep->doc, newchild);
+ if (newchild) {
+ dom_reconcile_ns(nodep->doc, newchild);
+ }
} else if (oldchild != newchild) {
if (newchild->doc == NULL && nodep->doc != NULL) {
xmlSetTreeDoc(newchild, nodep->doc);
$frag->appendChild(new DOMElement('third'));
$root->insertBefore($frag, $node);
+echo $dom->saveXML()."\n";
+
+$frag = $dom->createDocumentFragment();
+$root = $dom->documentElement;
+$root->replaceChild($frag, $root->firstChild);
+
echo $dom->saveXML();
?>
<?xml version="1.0"?>
<root><first/><second/><third/><fourth/></root>
+<?xml version="1.0"?>
+<root><second/><third/><fourth/></root>
+