To check if a SimpleXMLElement object SimpleXMLElement text value, you need to specify it as a string:
$desc = (string)$array['Description']; if (!empty($desc)) { echo $desc; }
Although you can directly echo contents of the SimpleXMLElement object, using its string value as a variable requires matching it. empty() should act on variable 1 so calling the __toString() implicit element will not work the same as with echo .
1 Starting with PHP 5.5, empty() can test an arbitrary result of an expression. This no longer requires a variable as an argument.
source share