0

Description:
------------
Doing the following SimpleXML text comparison does not give the expected results.

Reproduce code:
---------------

<?php
$sxe = simplexml_load_string('<root a="123" />');

echo $sxe['a']."\n";

if ($sxe['a'] == '123')
{
	echo 'They are equal.'."\n";
}
else
{
	echo 'They are not equal.'."\n";
}

?>

Expected result:
----------------
123
They are equal.

Actual result:
--------------
123
They are not equal.

2
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by pritaeas
0

it return object i think i should change it to

<pre>
<?php
$string = <<<EOF
<data>
<foo><bar>hello</bar></foo>
<foo><bar>world</bar></foo>
</data>
EOF;

$data = simplexml_load_string($string);

print_r($data);
print_r($data->foo);
?>
</pre>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.