php SimpleXML check if a child exists
I solved it by using the children()
function and doing a count()
on it, ignoring an PHP error if there are no children by putting an @ before the count-call. This is stupid, but it works:
$identification = $xml->identification;if (@count($identification->children()) == 0) $identification = $xml->Identification;
I hate this...