|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-04-01 11:38 UTC] jani@php.net
[2009-04-09 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 03:00:01 2025 UTC |
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.