ID:               36917
 Updated by:       [EMAIL PROTECTED]
 Reported By:      php at xmlnode dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         SimpleXML related
 Operating System: Debian
 PHP Version:      5.1.2
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

libxml_use_internal_errors(true);
var_dump(libxml_get_last_error());


Previous Comments:
------------------------------------------------------------------------

[2006-03-30 00:29:27] php at xmlnode dot com

Description:
------------
when simplexml_load_file fails (because the target xml file is empty
for example) there are multiple, basically useless, errors reported
that makes track_errors and $php_errormsg ineffective

My workaround has been to load the file using dom and grab it's
relevant error message then use interop to switch to simple if
everything is ok... definitely sub-optimal.

Reproduce code:
---------------
<?php
//the easiest test is to create an empty file called empty.xml

error_reporting(2047);
ini_set('display_errors',0);
ini_set('track_errors',1);

if( ! $x = simplexml_load_file('empty.xml') ){
        echo $php_errormsg;
}
?>

Expected result:
----------------
either:

"empty.xml:1: parser error : Document is empty"

or:

"empty.xml:1: parser error : Start tag expected, '<' not found"

Actual result:
--------------
"^"

If you enable display_errors you'll see that there are 3 warnings for
each 'error' ("Document is empty" and "Start tag expected")  There's
the relevant error, then an empty error message and then the last one
where the message is just "^" and because that's the last one, that's
the one stored in $php_errormsg.




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36917&edit=1

Reply via email to