in reply to Re^2: use XML::DOM - what to do with empty tags?
in thread use XML::DOM - what to do with empty tags?

ah, the example code I provided just assigns an empty string to $BusUrl, which you later use as an object (my bad). so really, what you'd want to do is something like this:
if($@) { # assign an empty (but defined) string to $bus_url $bus_url = ''; } else { # assign tag contents to $bus_url $bus_url = $BusUrl->item(0)->getChildAtIndex(0)->getData(); }
what you really want to do is follow mirod's advice and use the hasChildNodes method (note that he uses a much more flexible implementation than the following):
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 = ''; }

__________
The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
- Terry Pratchett