Help for this page

Select Code to Download


  1. or download this
    sub text_to_xml {
       my $s = shift;
       $s =~ s/]]>/]]>]]&gt;<![CDATA[/g;
       return "<![CDATA[$xml]]>";
    }
    
  2. or download this
    use HTML::Entities qw( encode_entities );
    
    sub text_to_xml {
        return encode_entities($text, '<&');
    }
    
  3. or download this
    my %lkup = (
        '<' => '&lt;',   # Not required.
    ...
        $s =~ s/([<&"])/$lkup{$1}/g;
        return qq{ $k="$v"};
    }