$ svn cp $SR/utils/trunk/src/gpstools $SR/utils/branches/gpst.postgis
[gpstools.git] / branches / gpst.postgis / GPSTxml.pm
blob1b789b4f9245d173c69eb068f018a73b86ad31cd
1 package GPSTxml;
3 #=======================================================================
4 # $Id$
6 # Character set: UTF-8
7 # ©opyleft 2002– Øyvind A. Holm <sunny@sunbase.org>
8 # License: GNU General Public License, see end of file for legal stuff.
9 #=======================================================================
11 use strict;
12 use warnings;
14 BEGIN {
15 use Exporter ();
16 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
18 my $rcs_id = '$Id$';
19 push(@main::version_array, $rcs_id);
20 $VERSION = ($rcs_id =~ / (\d+) /, $1);
22 @ISA = qw(Exporter);
23 @EXPORT = qw(&txt_to_xml &xml_to_txt);
24 %EXPORT_TAGS = ();
26 our @EXPORT_OK;
28 sub txt_to_xml {
29 # Convert plain text to XML {{{
30 my $Txt = shift;
31 $Txt =~ s/&/&amp;/gs;
32 $Txt =~ s/</&lt;/gs;
33 $Txt =~ s/>/&gt;/gs;
34 return($Txt);
35 # }}}
38 sub xml_to_txt {
39 # Convert XML data to plain text {{{
40 my $Txt = shift;
41 $Txt =~ s/&lt;/</gs;
42 $Txt =~ s/&gt;/>/gs;
43 $Txt =~ s/&amp;/&/gs;
44 $Txt =~ s/&quot;/"/gs;
45 $Txt =~ s/&apos;/'/gs;
46 return($Txt);
47 # }}}