Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
From the XML::Handler::Subs docs:
If the subclass implements `start_document()', `end_document()', `start_element()', and `end_element()', be sure to use `SUPER::' to call the the superclass methods also.
#!/usr/bin/perl use warnings; use strict; use XML::Parser::PerlSAX; use XML::Handler::Subs; my $parser = XML::Parser::PerlSAX->new(Handler => myHandler->new() ); $parser->parse(Source => {String => '<foo><bar>f*** it</bar></foo>'}); package myHandler; use base('XML::Handler::Subs'); sub new { my $type = shift; my $self = {@_}; return bless($self,$type); } sub start_element { my ($self,$properties) = @_; $self->SUPER::start_element(); print "started ",$properties->{Name},"\n"; } sub characters { my ($self, $properties) = @_; my $data = $properties->{Data}; print "$data\n"; print "These are the Names; ",@{$self->{Names}},"\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Using SUPER:: with XML::Handler::Subs?
by merlyn (Sage) on Nov 16, 2004 at 23:31 UTC | |
by Anonymous Monk on Nov 17, 2004 at 18:56 UTC |