Revision 264 (by dpavlin, 2004/03/12 15:33:13) branch for tehnika at r263
#
# small function that creates one xml tag
#

# Escape <, >, & and ", and to produce valid XML
my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');  
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;
}