ID: 35028
Comment by: shuyg at roadside dot nl
Reported By: lists at cyberlot dot net
Status: Assigned
Bug Type: SimpleXML related
Operating System: *
PHP Version: 5.1.0
Assigned To: helly
New Comment:
if ($test = simplexml_load_string($xml))
...
In php 5.1.0 this will return False (always). In 5.0.5 it returns True
when it succesfully parsed $xml.
I guess that this is what "lists at cyberlot dot net" realy wants.
Previous Comments:
------------------------------------------------------------------------
[2005-10-30 21:45:42] [EMAIL PROTECTED]
For 5.1.0 you'd need to use isset() instead of plain if() test since we
are too far in release process to have a big changes in it. But i will
do just after 5.1.0 is out the doors. Also it is fixed in HEAD.
Anyway i tried it with 5.0.6-dev and am nearly sure it does not work in
any version yet.
Btw, a boolean if() for normal php objects is a check whether the
object has any properties. This is probably not what you want. After
the change it results in true whenever there are sub elements,
attributes or a selected node.
------------------------------------------------------------------------
[2005-10-30 19:29:44] alex at whitewhale dot net
Note that if you change $string to:
$string = str_replace('><','> <',"<doc><login>kkl</
login><password>klk</password></doc>");
It passes.
------------------------------------------------------------------------
[2005-10-30 19:21:46] lists at cyberlot dot net
Description:
------------
$xml object returns false, this worked in RC1 fails in RC3 and RC4
never tested RC2
xml string of <doc>test</doc> DOES pass test. Its only when you have
subchildren children that the $xml object fails to pass.
<doc><test>test</test></doc> fails
<doc>test</doc> Passes.
if(is_object($xml)) { works, and is prob the best method to use but one
would expect $xml to be "true"
Realize this might be considered a dupe of bug #31045 however bug
#34199 suggests the same issue that states this is fixed.
Reproduce code:
---------------
<?
$string = "<doc><login>kkl</login><password>klk</password></doc>";
$xml = simplexml_load_String($string);
if($xml) {
echo "Passed test\n";
} else {
echo "Even though is object still failed false test\n";
}
?>
Expected result:
----------------
Expect output of Passed test
Actual result:
--------------
output of Even though is object still failed false test
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35028&edit=1