php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39157 can't catch simplexml error
Submitted: 2006-10-14 05:25 UTC Modified: 2006-10-14 08:50 UTC
From: xing at mac dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.1.6 OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xing at mac dot com
New email:
PHP Version: OS:

 

 [2006-10-14 05:25 UTC] 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...


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-14 08:50 UTC] chregu@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 11:01:30 2024 UTC