if( ref eq 'HASH' and exists $xml->{$usernumber}->{"user"}->{"firstname"} ) {...}