note 89010 added to function.simplexml-element-addChild
| From: | brettz9aaatyahdotcompany at osu1 dot php dot net | Date: | Wed, 18 Feb 2009 11:03:27 +0000 |
| Subject: | note 89010 added to function.simplexml-element-addChild | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150780@lists.php.net to get a copy of this message | ||
Chicken dot ofeathers comment was a little off. The incorrect example of:
<?php
$xml = new SimpleXMLElement('<root xmlns:itunes="http://example.com"/>');
$n = $xml->addChild("subtitle", "My Subtitle", "itunes");
?>
leads to:
<subtitle xmlns="itunes">My Subtitle</subtitle>
not <itunes:subtitle xmlns:itunes="itunes">My Subtitle</itunes:subtitle>
This is because "itunes" is already in the "http://example.com" namespace, and we're specifying a
new namespace of value "itunes" (it would be prefixed with "itunes:" if
xmlns:itunes were set to "itunes" on the parent, however).
Note that you cannot control the prefix from this function (as with addAttribute)--you must
apparently rely on an existing namespace, as per chicken dot ofeather's comments.
----
Server IP: 69.147.83.197
Probable Submitter: 116.76.201.112
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-element-addChild.php
Edit -- https://master.php.net/note/edit/89010
Del: integrated -- https://master.php.net/note/delete/89010/integrated
Del: useless -- https://master.php.net/note/delete/89010/useless
Del: bad code -- https://master.php.net/note/delete/89010/bad+code
Del: spam -- https://master.php.net/note/delete/89010/spam
Del: non-english -- https://master.php.net/note/delete/89010/non-english
Del: in docs -- https://master.php.net/note/delete/89010/in+docs
Del: other reasons-- https://master.php.net/note/delete/89010
Reject -- https://master.php.net/note/reject/89010
Search -- https://master.php.net/manage/user-notes.php