sub mapxml { my $xml = shift; my ($tag, $value, %xmlhash); my @lines = (split /\n/, $xml); chomp @lines; while (@lines) { my $line = shift @lines; ($tag,$value) = ($line =~ /<([\w:]+?\/?)>([^<]*)/); next if (! defined($tag) || (substr($tag,-1) eq '/')); if ($value =~ /[\w:-\\]+/) { $xmlhash{$tag} = $value; } else { my $contents = ""; while (1) { $line = shift (@lines); last if ($line eq ''); $contents .= $line . "\n"; } $xmlhash{$tag} = mapxml($contents); } } return \%xmlhash; }