note 91232 added to function.simplexml-element-addChild

From: Date: Sun, 31 May 2009 23:38:03 +0000
Subject: note 91232 added to function.simplexml-element-addChild
Groups: php.notes 
Request: Send a blank email to php-notes+get-156205@lists.php.net to get a copy of this message
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: $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: $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. ---- Server IP: 64.71.164.2 Probable Submitter: 24.238.90.139 ---- Manual Page -- http://www.php.net/manual/en/function.simplexml-element-addChild.php Edit -- https://master.php.net/note/edit/91232 Del: integrated -- https://master.php.net/note/delete/91232/integrated Del: useless -- https://master.php.net/note/delete/91232/useless Del: bad code -- https://master.php.net/note/delete/91232/bad+code Del: spam -- https://master.php.net/note/delete/91232/spam Del: non-english -- https://master.php.net/note/delete/91232/non-english Del: in docs -- https://master.php.net/note/delete/91232/in+docs Del: other reasons-- https://master.php.net/note/delete/91232 Reject -- https://master.php.net/note/reject/91232 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#156205) next »