<?xml version="1.0" encoding="windows-1252"?>
<node id="64366" title="Re: Re: Re: Re: XML::Parser Tutorial" created="2001-03-14 10:41:20" updated="2005-07-19 14:08:39">
<type id="11">
note</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
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.
&lt;p&gt;
Witness:
&lt;p&gt;
&lt;pre&gt;
my $handler = bless {}, "MyHandler";
my $p = XML::Parser-&gt;new(Handlers =&gt; {
   Start =&gt; sub { $handler-&gt;handle_start(@_) } 
});

package MyHandler;

sub handle_start {
  my ($handler, $p, $element, %attribs) = @_;
  ...
}
&lt;/pre&gt;
</field>
<field name="root_node">
62782</field>
<field name="parent_node">
62789</field>
<field name="reputation">
13</field>
</data>
</node>
