1--TEST-- 2Delayed freeing text node 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7$doc = new DOMDocument; 8// Text nodes are special as the underlying library has a tendency to merge adjacent ones 9$text1 = $doc->appendChild($doc->createElement('container')) 10 ->appendChild($doc->createTextNode('my text 1')); 11$text2 = $doc->documentElement->appendChild($doc->createTextNode('my text 2')); 12echo $doc->saveXML(), "\n"; 13$text1->parentNode->remove(); 14echo $doc->saveXML(), "\n"; 15echo $doc->saveXML($text1), "\n"; 16echo $doc->saveXML($text2), "\n"; 17var_dump($text1->parentNode, $text2->parentNode); 18var_dump($text1->nextSibling, $text2->previousSibling); 19?> 20--EXPECT-- 21<?xml version="1.0"?> 22<container>my text 1my text 2</container> 23 24<?xml version="1.0"?> 25 26my text 1 27my text 2 28NULL 29NULL 30NULL 31NULL 32