ID Comparison in XML Elements

0

I'm doing a check between 2 ids of 2 different elements in XML , but when I make the comparison the result is always false even though gettype is the same result and the number is also the same result.

To perform the verification I have 2 loops , one inside the other, the first is the result of the equality comparison:

var_dump($filme->attributes()['id'] == $m->attributes()['id']);

And the second is the comparison of types and id's :

echo get_class($filme->attributes()['id']) . ' ' .$filme->attributes()['id'] 
. ' --> ' . 
get_class($m->attributes()['id']) . ' ' . $m->attributes()['id'] . '<hr/>';

Below the full list:

bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5718

bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5764

bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5767

bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5792

bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5794

bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 6015

bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 6031

bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 6052

Note in the fifth line of the above result that the result is the same however the check is false

bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5794

I have already checked the types and values and I keep getting false .

    
asked by anonymous 02.04.2017 / 22:45

1 answer

0

So it does not work?

var_dump((string)$filme->attributes()['id'] == (string)$m->attributes()['id']);
    
03.04.2017 / 17:01