#39157 [Opn->Bgs]: can't catch simplexml error
| From: | chregu@php.net | Date: | Sat, 14 Oct 2006 08:50:02 +0000 |
| Subject: | #39157 [Opn->Bgs]: can't catch simplexml error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-103541@lists.php.net to get a copy of this message | ||
ID: 39157
Updated by: chregu@php.net
Reported By: xing at mac dot com
-Status: Open
+Status: Bogus
Bug Type: SimpleXML related
Operating System: linux
PHP Version: 5.1.6
New Comment:
Use the http://www.php.net/manual/en/function.libxml-get-
errors.php et al. functions available since 5.1 for catching
xml errors.
We won't change anything in the way it's done right now.
Previous Comments:
------------------------------------------------------------------------
[2006-10-14 05:25:30] xing at mac dot com
Description:
------------
Cannot catch a simple loading error when using simplexml_load_string()
loading an invalid xml string.
I understand that that E_WARNING, E_ERROR etc are not exceptions but
realisticlly, I expect a loading function to throw an exception when it
fails to load a object, not a uncatchable "warning". It also be invalid
to say this error class is a "warning" as it is most definitely an
error.
Reproduce code:
---------------
<?php
try {
$x = simplexml_load_string("adfasdf");
print_r($x);
}
catch (Exception $e) {
echo "toast";
}
?>
Expected result:
----------------
toast
Actual result:
--------------
Warning: simplexml_load_string(): Entity: line 1: parser error : Start
tag expected, '<' not found in...
Warning: simplexml_load_string(): adfasdf in...
Warning: simplexml_load_string(): ^ in...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39157&edit=1