php xml object compare
<p>I get data from an XML object in PHP and use the "==" operator, but we do not get equality. It seems like a very basic question, but I cannot find it anywhere.</p>

<p>Minimal example:</p>

<pre><code>&lt;?php
// Load the file
$xmlData = "&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
&lt;root&gt;
&lt;a&gt;animalia&lt;/a&gt;
&lt;b&gt;arthropoda
&lt;parent&gt;animalia&lt;/parent&gt;
&lt;/b&gt;
&lt;/root&gt;";

$xml=simplexml_load_string($xmlData) or die("Error: Cannot create object");
print_r($xml);

//Extract the data

$x=$xml-&gt;a;
$y=$xml-&gt;b-&gt;parent;

// Test whether they are equal

if ($x==$y) {
  echo $x." = ".$y;
}
else {
  echo "'".$x."' does not equal '".$y."'";
}
?&gt;
</code></pre>

<p>This gives me the result: 'animalia' does not equal 'animalia'</p>

<p>Note, if I write either</p>

<pre><code>print_r($x); 
</code></pre>

<p>or </p>

<pre><code>print_r($x);
</code></pre>

<p>I get the output: SimpleXMLElement Object ( [0] => animalia )</p>

<p>So the question is, why these are not considered equal? Thanks in advance.</p>