note 73362 added to ref.simplexml

From: Date: Tue, 20 Feb 2007 01:57:37 +0000
Subject: note 73362 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-123588@lists.php.net to get a copy of this message
It doesn't mention this anywhere, but creationg a new SimpleXMLElement object from a non-valid string throws an exception. It looks ugly in the php log as it dumps the stack in multiple lines. The correct way to create a new SimpleXMLElement object is like so: <?php $xmlstr = ''; // empty to throw an exception try { $xml = new SimpleXMLElement($xmlstr); } catch (Exception $e) { // handle the error echo '$xmlstr is not a valid xml string'; } ?> ---- Server IP: 216.235.15.211 Probable Submitter: 206.191.39.15 ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- https://master.php.net/note/edit/73362 Del: integrated -- https://master.php.net/note/delete/73362/integrated Del: useless -- https://master.php.net/note/delete/73362/useless Del: bad code -- https://master.php.net/note/delete/73362/bad+code Del: spam -- https://master.php.net/note/delete/73362/spam Del: non-english -- https://master.php.net/note/delete/73362/non-english Del: in docs -- https://master.php.net/note/delete/73362/in+docs Del: other reasons-- https://master.php.net/note/delete/73362 Reject -- https://master.php.net/note/reject/73362 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123588) next »