From: php at sebastianmendel dot de Operating system: PHP version: 5.4.5 Package: SimpleXML related Bug Type: Bug Bug description:BC: in PHP 5.4 empty() reports true for simplexmlelement
Description: ------------ When laoding XML into SimpleXMLElement and iterating with ->children() empty() reports true for SimpleXMLElement objects. In PHP 5.3.16 empty() returns false. In PHP 5.4.5 empty() returns true. Test script: --------------- $xml = <<<EOT <?xml version="1.0" ?> <Y><X>6098881</X></Y> EOT; $sxml = new SimpleXMLElement($xml); foreach ($sxml->children() as $xmlKey => $xmlNode) { var_dump( empty($xmlNode), (string) $xmlNode, $xmlNode->asxml() ); } $xmlNode = new SimpleXMLElement('<X>501936634a721</X>'); var_dump( empty($xmlNode), (string) $xmlNode, $xmlNode->asxml() ); Expected result: ---------------- bool(false) string(7) "6098881" string(14) "<X>6098881</X>" bool(false) string(13) "501936634a721" string(43) "<?xml version="1.0"?> <X>501936634a721</X> " Actual result: -------------- bool(true) string(7) "6098881" string(14) "<X>6098881</X>" bool(false) string(13) "501936634a721" string(43) "<?xml version="1.0"?>\n<X>501936634a721</X>\n" -- Edit bug report at https://bugs.php.net/bug.php?id=62717&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62717&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62717&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62717&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62717&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62717&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62717&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62717&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62717&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62717&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62717&r=support Expected behavior: https://bugs.php.net/fix.php?id=62717&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62717&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62717&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62717&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62717&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62717&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62717&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62717&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62717&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62717&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62717&r=mysqlcfg