note 49230 added to function.dom-domdocument-createelement

From: Date: Thu, 20 Jan 2005 22:08:47 +0000
Subject: note 49230 added to function.dom-domdocument-createelement
Groups: php.notes 
Request: Send a blank email to php-notes+get-83699@lists.php.net to get a copy of this message
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); ?> ---- Manual Page -- http://www.php.net/manual/en/function.dom-domdocument-createelement.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49230 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49230&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49230&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49230&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49230&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49230&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49230&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83699) next »