note 80492 added to function.simplexml-element-addChild
| From: | chicken dot ofeathers at gmail dot com | Date: | Fri, 18 Jan 2008 19:57:34 +0000 |
| Subject: | note 80492 added to function.simplexml-element-addChild | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135205@lists.php.net to get a copy of this message | ||
Correct namespace usage:
<?php
$xml = new SimpleXMLElement('<root xmlns:itunes="http://apple.com"/>');
$n = $xml->addChild("subtitle", "My Subtitle", " http://apple.com");
?>
Incorrect namespace usage:
<?php
$xml = new SimpleXMLElement('<root xmlns:itunes="http://apple.com"/>');
$n = $xml->addChild("subtitle", "My Subtitle", " itunes");
?>
The latter incorrect usage results in the following superfluous xmlns attribute:
<itunes:subtitle xmlns:itunes="itunes">My Subtitle</itunes:subtitle>
Whereas all you want is this:
<itunes:subtitle>My Subtitle</itunes:subtitle>
----
Server IP: 69.147.83.197
Probable Submitter: 67.78.181.222
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-element-addChild.php
Edit -- https://master.php.net/note/edit/80492
Del: integrated -- https://master.php.net/note/delete/80492/integrated
Del: useless -- https://master.php.net/note/delete/80492/useless
Del: bad code -- https://master.php.net/note/delete/80492/bad+code
Del: spam -- https://master.php.net/note/delete/80492/spam
Del: non-english -- https://master.php.net/note/delete/80492/non-english
Del: in docs -- https://master.php.net/note/delete/80492/in+docs
Del: other reasons-- https://master.php.net/note/delete/80492
Reject -- https://master.php.net/note/reject/80492
Search -- https://master.php.net/manage/user-notes.php