note 80492 deleted from function.simplexml-element-addChild by danbrown
| From: | danbrown@php.net | Date: | Wed, 18 Feb 2009 14:36:04 +0000 |
| Subject: | note 80492 deleted from function.simplexml-element-addChild by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150800@lists.php.net to get a copy of this message | ||
Note Submitter: chicken dot ofeathers at gmail dot com
----
Correct namespace usage:
<?php
$xml = new SimpleXMLElement('<root xmlns:itunes="http://example.com"/>');
$n = $xml->addChild("subtitle", "My Subtitle", " http://example.com");
?>
Incorrect namespace usage:
<?php
$xml = new SimpleXMLElement('<root xmlns:itunes="http://example.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>