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 Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or 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

Add a Patch

Pull Requests

Add a Pull Request

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 Mar 28 13:01:28 2024 UTC