From: 007not at gmail dot com Operating system: win xp sp2 PHP version: 5.2.5 PHP Bug Type: SimpleXML related Bug description: simpleXML thinks that comment is node
Description: ------------ also see http://bugs.php.net/43392 >[EMAIL PROTECTED] comment: >This is just normal and expected behaviour. ><foo><!-- comment --></foo> is not same as <foo></foo>. >(try var_dump($xml); to see what happens) i made some new test for you, and try to var_dump() this var_dump(array(/*'comment' => 'value'*/)); <foo><!-- comment --></foo> === <foo></foo> && array(/*'comment' => 'value'*/) === array('comment' => 'value') is it still be same ? ;) Reproduce code: --------------- $string = <<<XML <?xml version='1.0'?> <document> <node><!-- comment --></node> <otherNode></otherNode> <comment>value</comment> </document> XML; $xml = simplexml_load_string($string); //note: xdebug used //first test var_dump($xml->node); var_dump($xml->otherNode); /* Expected result: ---------------- null object(SimpleXMLElement)[2] public 'comment' => string 'value' (length=5) Actual result: -------------- object(SimpleXMLElement)[2] public 'comment' => object(SimpleXMLElement)[4] object(SimpleXMLElement)[2] public 'comment' => string 'value' (length=5) */ //second test $i = 0; foreach ($xml->node as $node) { $i++; } echo $i . "\n"; $i = 0; foreach ($xml->otherNode as $node) { $i++; } echo $i . "\n"; /* Expected result: ---------------- 0 1 Actual result: -------------- 1 1 */ //third test var_dump($xml->node->comment); var_dump($xml->otherNode->comment); //check magic echo "node:\n"; if (is_object($xml->node->comment)) { echo "is_object === TRUE \n"; } if (isset($xml->node->comment)) { echo "isset === TRUE \n"; } //but if (strlen($xml->node->comment) > 0) { echo "strlen > 0\n"; } if (strlen($xml->node->comment) == 0) { echo "strlen == 0\n"; } echo "otherNode:\n"; if (is_object($xml->otherNode->comment)) { echo "is_object === TRUE \n"; } if (isset($xml->otherNode->comment)) { echo "isset === TRUE \n"; } /* Expected result: ---------------- node: is_object === TRUE isset === TRUE strlen == 0 otherNode: is_object === TRUE Actual result: -------------- node: is_object === TRUE strlen == 0 otherNode: is_object === TRUE */ Expected result: ---------------- see code Actual result: -------------- see code -- Edit bug report at http://bugs.php.net/?id=43542&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43542&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43542&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43542&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43542&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43542&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43542&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43542&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43542&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43542&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43542&r=support Expected behavior: http://bugs.php.net/fix.php?id=43542&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43542&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43542&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43542&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43542&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43542&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43542&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43542&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43542&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43542&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43542&r=mysqlcfg