File Coverage

examples/MyHandler.pm
Criterion Covered Total %
statement 2 17 11.7
branch n/a
condition n/a
subroutine 1 6 16.6
pod 0 6 0.0
total 3 29 10.3


line stmt bran cond sub pod time code
1             # An example of simple SAX handler
2              
3             package MyHandler;
4              
5             sub new {
6 1     1 0 8 my $type = shift;
7 1         6 return bless {}, $type;
8             }
9              
10             sub start_document {
11 0     0 0   my ($self, $document) = @_;
12            
13 0           print "Starting document\n";
14             }
15              
16             sub end_document {
17 0     0 0   my ($self, $document) = @_;
18            
19 0           print "Ending document\n";
20 0           return 1;
21             }
22              
23             sub start_element {
24 0     0 0   my ($self, $element) = @_;
25            
26 0           print "<$element->{Name} ";
27             # print "xmlns:$element->{Prefix}=\"$element->{NamespaceURI}\" ";
28 0           foreach (keys %{$element->{Attributes}}) {
  0            
29             # SAX2 way
30 0           print "$element->{Attributes}->{$_}->{Name}=\"$element->{Attributes}->{$_}->{Value}\" ";
31             # SAX1 alternative way
32             # print "$_=\"$element->{Attributes}->{$_}\" ";
33             }
34 0           print ">\n";
35             }
36              
37             sub end_element {
38 0     0 0   my ($self, $element) = @_;
39            
40 0           print "{Name}>\n";
41             }
42              
43             sub characters {
44 0     0 0   my ($self, $characters) = @_;
45            
46 0           print "$characters->{Data}\n";
47             }
48              
49             1;