| Revision 311 (by dpavlin, 2004/04/17 22:31:43) |
|---|
#
# small function that creates one xml tag
#
# Escape <, >, & and ", and to produce valid XML
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"');
my $escape_re = join '|' => keys %escape;
sub xmlify {
my $tag = shift;
my $out;
$out .= " <$tag>";
foreach my $v (@_) {
$v =~ s/($escape_re)/$escape{$1}/g;
$out .= $v;
}
$out .= "</$tag>\n";
return $out;
}