Re: SimpleXML add a node

From: Date: Fri, 11 Mar 2005 22:40:42 +0000
Subject: Re: SimpleXML add a node
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-210562@lists.php.net to get a copy of this message
>> php.net/dom > > ?? > > Like this? > > --- > > try { > > $dom = new DOMDocument(); > > $config = > $dom->appendChild($dom->importNode(dom_import_simplexml($this->configXML),true)); > > $config->appendChild( $dom->createElement(($mode? > 'softactive':'active')) > ); > > $this->configXML = simplexml_import_dom($config); > > } catch(Exception $e) {} I dunno about that whole try/catch thing, but if you're not going to USE it to catch the errors, then you might as well be old school and check the return values of all these functions. > It ist strange... It runs one time, the second time I receive the > following > error. Since it "works" once and not the second time, I'd be looking to see if the XML produced on the first go-around is actually VALID, since, if it's not, that would cause this problem, I think. > Warning: DOMDocument::importNode() [function.importNode]: Cannot import: > Node Type Not Supported in ... So what's the Node Type (whatever that is) of the Node you are importing? > Warning: appendChild() expects parameter 1 to be DOMNode, boolean given in > ... > > Fatal error: Call to a member function appendChild() on a non-object in > ... -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#210562) next »