| 1 | =head1 NAME | ||
| 2 | |||
| 3 | XML::XMLWriter::PCData - XML::XMLWriter parsed character data class | ||
| 4 | |||
| 5 | =cut | ||
| 6 | |||
| 7 | ###################################################################### | ||
| 8 | |||
| 9 | package XML::XMLWriter::PCData; | ||
| 10 | require 5.8.0; | ||
| 11 | |||
| 12 | ###################################################################### | ||
| 13 | |||
| 14 | use strict; | ||
| 15 | |||
| 16 | ###################################################################### | ||
| 17 | |||
| 18 | =head2 Methods | ||
| 19 | |||
| 20 | =head3 new (@text) | ||
| 21 | |||
| 22 | @text must be an array of strings. | ||
| 23 | |||
| 24 | Every element of @text is parsed and saved. Parsing sofar only means | ||
| 25 | that &, < and > are replaced by their XML entities (&, < and | ||
| 26 | >). | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | ###################################################################### | ||
| 31 | |||
| 32 | sub new { | ||
| 33 | my($class, @text) = @_; | ||
| 34 | my $self = bless({}, ref($class) || $class); | ||
| 35 | for(my $i=0; $i<@text; $i++) { | ||
| 36 | $text[$i] =~ s/&/&/g; | ||
| 37 | $text[$i] =~ s/</</g; | ||
| 38 | $text[$i] =~ s/>/>/g; | ||
| 39 | } | ||
| 40 | $self->{data} = \@text; | ||
| 41 | return $self; | ||
| 42 | } | ||
| 43 | |||
| 44 | ###################################################################### | ||
| 45 | |||
| 46 | =head3 get () | ||
| 47 | |||
| 48 | Returns the strings of parsed character data in an array. | ||
| 49 | |||
| 50 | =cut | ||
| 51 | |||
| 52 | ###################################################################### | ||
| 53 | |||
| 54 | sub _get { | ||
| 55 | my($self) = @_; | ||
| 56 | return @{$self->{data}}; | ||
| 57 | } | ||
| 58 | |||
| 59 | ###################################################################### | ||
| 60 | |||
| 61 | return 1; | ||
| 62 | |||
| 63 | __END__ |