Here is a modified version of the code that you posted that should explain it. <?php $xmlData = <<<XMLDATA <?xml version="1.0" encoding="ISO-8859-1" ?> <root> <subElement>content</subElement> </root> XMLDATA; $dom = new DomDocument; $dom->loadXML( $xmlData ); $dom2 = new DomDocument; $fragment = $dom2->createDocumentFragment(); foreach( $dom->childNodes AS $node ) { $newNode = $dom2->importNode( $node, true ); /** This is the (undocumented?) way to get the value of a text node */ var_dump($newNode->nodeValue); $fragment->appendChild( $newNode ); /** Now we see what the value of the $fragment is */ var_dump($fragment); } $dom2->appendChild( $fragment ); /** Finally, we echo the XML of the new document */ echo $dom2->saveXML(); ?> -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-general&w=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
Attachment:
signature.asc
Description: OpenPGP digital signature