note 49230 deleted from function.dom-domdocument-createelement by didou

From: Date: Sat, 30 Dec 2006 03:08:48 +0000
Subject: note 49230 deleted from function.dom-domdocument-createelement by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121043@lists.php.net to get a copy of this message
Note Submitter: brian dot sanders at cometsystems dot com ---- Regarding paul squigly-symbol allofus dot org's comment below: Neither this method, nor setting the nodeValue property, encodes ampersands (&). You must manually encode them or use the textContent property (which encodes them as expected.) However, setting textContent on an element created by DOMDocument::createElement does NOT work. You must create a text node, set its textContent, then append the text node to your element: <?php $dom = DomDocument::loadXML(<<<XML <?xml version="1.0"?> <foo/> XML ); $element = $dom->createElement('bar'); $element->appendChild($dom->createTextNode('pb & j')); $dom->documentElement->appendChild($element); ?>

« previous php.notes (#121043) next »