Re: SimpleXML addChild() namespace problem

From: Date: Tue, 15 Jan 2008 13:36:27 +0000
Subject: Re: SimpleXML addChild() namespace problem
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-267283@lists.php.net to get a copy of this message
On Jan 14, 2008 11:21 PM, Carole E. Mah <carole.mah@gmail.com> wrote: > Yes, I tried the following: > > > http://us3.php.net/manual/en/function.dom-domdocument-createelementns.php > > Same results. > based upon information from bug #43221, if you define the namespace beforehand it will work. <?php $xml = new SimpleXMLElement('<root xmlns:itunes="http://apple.com"/>'); $n = $xml->addChild("subtitle", "Musical Mockery", "http://apple.com"); print_r($xml->asXml()); ?> produces: <?xml version="1.0"?> <root xmlns:itunes="http://apple.com"><itunes:subtitle>Musical Mockery</itunes:subtitle></root> -nathan

« previous php.general (#267283) next »