From:             cupidle at gmx dot de
Operating system: WinXP SP2
PHP version:      5.2.9
PHP Bug Type:     SimpleXML related
Bug description:  simple_xml_load string fails without error message when 
encooding broken

Description:
------------
When simplexml_load_string fails loading xml it returns FALSE. 

An error message should be available via error_get_last. This is not the
case when certain encoding errors are encountered.

Reproduce code:
---------------
I'm using this code to gracefully fall back on encoding errors:

    $xml = simplexml_load_string($data);

    // character encoding warning- hack
    if ($xml === false) 
    {
        $error = error_get_last();
     
        // this is nasty- sometimes simplexml_load_string fails but
doesn't raise an error
#        if (eregi('simplexml_load_string', $error['message']))
        {
            $xml = simplexml_load_string(utf8_encode($data));
        }
    }


Expected result:
----------------
This does _sometimes_ work (i.e. call the innermost, encoded version), but
not always. For example, simplexml_load_string silently fails without error
message when processing data from amazon like this:

http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&Version=2007-12-24&Operation=ItemSearch&AssociateTag=cpuidle-20&AWSAccessKeyId=1CB01P12WQBRDNH10NR2&ItemPage=1&Keywords=Star+Wars%3A+Episode+1&;

Actual result:
--------------
simplexml_load_string returns FALSE, but does not return error message.

-- 
Edit bug report at http://bugs.php.net/?id=47734&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47734&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47734&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47734&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47734&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47734&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47734&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47734&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47734&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47734&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47734&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47734&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47734&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47734&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47734&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47734&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47734&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47734&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47734&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47734&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47734&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47734&r=mysqlcfg

Reply via email to