Re: SimpleXML addChild() namespace problem

From: Date: Fri, 18 Jan 2008 19:48:33 +0000
Subject: Re: SimpleXML addChild() namespace problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-267582@lists.php.net to get a copy of this message
On Jan 18, 2008 12:22 PM, Nathan Nobbe <quickshiftin@gmail.com> wrote: > Are you trying to read an existing document into a SimpleXMLElement, or are > you trying to create a SimpleXMLElement instance and generate a document > from that? > My impression was you were trying to do the later; please clarify and if you > are trying to do the later, post the code you are using to create the > SimpleXMLElement instance and generate the output youve posted. Nathan, I am trying to to the latter -- create a SimpleXMLElement instance and generate a document from that. Thank you very much for all your examples and patience. I now see the very silly mistake I made. Correct (from your example): $xml = new SimpleXMLElement('<root xmlns:itunes="http://apple.com"/>'); $n = $xml->addChild("subtitle", "Musical Mockery", " http://apple.com"); Incorrect (what I was doing): $xml = new SimpleXMLElement('<root xmlns:itunes="http://apple.com"/>'); $n = $xml->addChild("subtitle", "Musical Mockery", " itunes"); To be fair, there really isn't an example of this on PHP.net. Nonetheless, I feel a bit foolish for having wasted your time with this. Thank you for your help. Carole

« previous php.general (#267582) next »