my $BusUrl = $contact->getElementsByTagName( "BusinessUrl" ); # check if tag is defined and has children if (defined $BusUrl && $BusUrl->hasChildNodes) { $bus_url = $BusUrl->item( 0 )->getChildAtIndex( 0 )->getData(); } # otherwise assign an empty string else { $bus_url = ''; }