| MKDoc-XML documentation | Contained in the MKDoc-XML distribution. |
MKDoc::XML::Encode - Encodes XML entities
use MKDoc::XML::Encode;
# $xml is now "Chris' Baloon"
my $xml = MKDoc::XML::Encode->process ("Chris' Baloon");
MKDoc::XML::Encode is a very simple module which encodes the following entities.
' " > < &
That's it.
This module and its counterpart MKDoc::XML::Decode are used by MKDoc::XML::Dumper to XML-encode and XML-decode litterals.
Does what is said in the summary.
Copyright 2003 - MKDoc Holdings Ltd.
Author: Jean-Michel Hiver
This module is free software and is distributed under the same license as Perl itself. Use it at your own risk.
MKDoc::XML::DecodeHO MKDoc::XML::Encode
| MKDoc-XML documentation | Contained in the MKDoc-XML distribution. |
# ------------------------------------------------------------------------------------- # MKDoc::XML::Encode # ------------------------------------------------------------------------------------- # Author : Jean-Michel Hiver. # Copyright : (c) MKDoc Holdings Ltd, 2003 # # This modules encodes XML entities & > < " and '. # # This module is distributed under the same license as Perl itself. # ------------------------------------------------------------------------------------- package MKDoc::XML::Encode; use warnings; use strict; our %XML_Encode = ( '&' => 'amp', '<' => 'lt', '>' => 'gt', '"' => 'quot', "'" => 'apos', ); our $XML_Encode_Pattern = join ("|", keys %XML_Encode); sub process { (@_ == 2) or warn "MKDoc::XML::Encode::process() should be called with two arguments"; my $class = shift; my $data = join '', map { (defined $_) ? $_ : '' } @_; $data =~ s/($XML_Encode_Pattern)/&$XML_Encode{$1};/go; return $data; } 1; __END__