Re: SimpleXML add a node

From: Date: Sat, 12 Mar 2005 22:25:44 +0000
Subject: Re: SimpleXML add a node
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-210600@lists.php.net to get a copy of this message
Richard Lynch wrote:
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
the try/catch block only catch exceptions, you still have to handle the std errors as normally would - for the old school its business as usual, only this simester there are a couple of new kids in the class :-). I'm pretty sure there was alot of discussion about whether to throw exceptions or trigger errors in the new php5 extensions. I can't actually think of any place in php5 or the extensions I use where the engine throws an Exceptions... at any rate all my Exceptions are userland generated. like for instance when any object is not of the right class I might throw an Exception. Exceptions are really cool, but they are not are a replacement for var & error checking. behold the 'instanceof' keyword. it is good :-) (free tip: javascript has a 'instanceof' keyword that is indentical to the php keyword in usage, AFAICT). the rest (xml) is all french to me :-/


« previous php.general (#210600) next »