Line # Revision Author
1 10 dpavlin #
2 # small function that creates one xml tag
3 #
4
5 # Escape <, >, & and ", and to produce valid XML
6 my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');
7 my $escape_re = join '|' => keys %escape;
8
9 sub xmlify {
10 my $tag = shift;
11 my $out;
12
13 $out .= " <$tag>";
14 foreach my $v (@_) {
15 $v =~ s/($escape_re)/$escape{$1}/g;
16 $out .= $v;
17 }
18 $out .= "</$tag>\n";
19 return $out;
20 }