note 80492 modified in function.simplexml-element-addChild by thiago

From: Date: Wed, 20 Aug 2008 02:02:11 +0000
Subject: note 80492 modified in function.simplexml-element-addChild by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143648@lists.php.net to get a copy of this message
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> --was-- 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> http://php.net/manual/en/function.simplexml-element-addChild.php

« previous php.notes (#143648) next »