Merge branch 'strip_id'
[gpstools.git] / GPSTxml.pm
blobe523d98d5e9402725a6d8e4fda4453561fef1c3b
1 package GPSTxml;
3 #=======================================================================
4 # GPSTxml.pm
5 # File ID: 7065d156-fafa-11dd-a242-000475e441b9
7 # Character set: UTF-8
8 # ©opyleft 2002– Øyvind A. Holm <sunny@sunbase.org>
9 # License: GNU General Public License, see end of file for legal stuff.
10 #=======================================================================
12 use strict;
13 use warnings;
15 BEGIN {
16 use Exporter ();
17 our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
19 @ISA = qw(Exporter);
20 @EXPORT = qw(&txt_to_xml &xml_to_txt);
21 %EXPORT_TAGS = ();
23 our @EXPORT_OK;
25 sub txt_to_xml {
26 # Convert plain text to XML {{{
27 my $Txt = shift;
28 $Txt =~ s/&/&amp;/gs;
29 $Txt =~ s/</&lt;/gs;
30 $Txt =~ s/>/&gt;/gs;
31 return($Txt);
32 # }}}
35 sub xml_to_txt {
36 # Convert XML data to plain text {{{
37 my $Txt = shift;
38 $Txt =~ s/&lt;/</gs;
39 $Txt =~ s/&gt;/>/gs;
40 $Txt =~ s/&amp;/&/gs;
41 $Txt =~ s/&quot;/"/gs;
42 $Txt =~ s/&apos;/'/gs;
43 return($Txt);
44 # }}}