Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Re: Re: XML::Parser Tutorial

by Anonymous Monk
on Mar 14, 2001 at 15:41 UTC ( #64366=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Re: XML::Parser Tutorial
in thread XML::Parser Tutorial

The way to do this, without relying on the fact that the $p is a hashref, is to pass a closure as the handlers, and have an object that you created saved in the closure. This is how PerlSAX is implemented.

Witness:

my $handler = bless {}, "MyHandler";
my $p = XML::Parser->new(Handlers => {
   Start => sub { $handler->handle_start(@_) } 
});

package MyHandler;

sub handle_start {
  my ($handler, $p, $element, %attribs) = @_;
  ...
}


Comment on Re: Re: Re: Re: XML::Parser Tutorial

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://64366]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-07-28 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls