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.

Recommended Answers

All 7 Replies

what server do you us

what server do you use

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.