note 40738 modified in ref.simplexml by aidan
| From: | aidan@php.net | Date: | Mon, 28 Jun 2004 00:35:50 +0000 |
| Subject: | note 40738 modified in ref.simplexml by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71982@lists.php.net to get a copy of this message | ||
I had a problem detecting the existance of a node, in SimpleXML. Meaning, if exists, even if empty.
I solved this stupid problem by using this function:
<?php
function node_exist($objSXml)
{
$objTemp = (object) $objSXml;
return ($objTemp->scalar != null);
}
?>
It would be nice to have something more logical, as SimpleXML function. Or, when you cast to (bool),
to evaluate to node existance.
--was--
I had a problem detecting the existance of a node, in SimpleXML. Meaning, if exists, even if empty.
I solved this stupid problem by using this function:
function node_exist($objSXml)
{
$objTemp = (object) $objSXml;
return ($objTemp->scalar != null);
}
It would be nice to have something more logical, as SimpleXML function. Or, when you cast to (bool),
to evaluate to node existance.
http://php.net/manual/en/ref.simplexml.php