note 91232 deleted from simplexmlelement.addChild by danbrown

From: Date: Fri, 28 Jan 2011 14:34:23 +0000
Subject: note 91232 deleted from simplexmlelement.addChild by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176457@lists.php.net to get a copy of this message
Note Submitter: d dot smith at sharedlog dot com ---- If you want to add a child element that is prefixed by a namespace like this one: <content:encoded> then this is what you need to do: <?php $parent->addChild('content:encoded', 'some actual content here', ''http://purl.org/rss/1.0/modules/content/''); ?> Make sure you declared the namespace at some parent element, preferrably at root: <root xmlns:content="http://purl.org/rss/1.0/modules/content/"> This will create a child element that will look like this when object dumpted as xml string: <content:encoded> If you are adding child this way: <?php $parent->addChild('encoded', 'some actual content here', ''content''); ?> then your child element will look like this: <encoded xmlns="content"> which is also a valid xml tag and basically has the same exact value as <content:encoded> but just looks different.

« previous php.notes (#176457) next »