in reply to Re: XML-Parser-PerlSAX how to get the BytePosition value
in thread XML-Parser-PerlSAX how to get the BytePosition value

yes I saw that piece of code before posting the above message.
in the listing number:

1. Are there any internel hooks that can return the "BytePosition - The current byte position of the parse."

what I meant is:

What ever the data processing that I make is in call back routines. Where as the function XML::Parser::PerlSAX->location() is not a part of callback routine, instead it is a XML::Parser::PerlSAX built in function.

AFIAK, I can't call this function (XML::Parser::PerlSAX->location) inside any of the call back routine. So only time I call this function is when I have finished parsing my entire XML doc. (correct me if I am wrong.)

  • Comment on Re^2: XML-Parser-PerlSAX how to get the BytePosition value

Replies are listed 'Best First'.
Re^3: XML-Parser-PerlSAX how to get the BytePosition value
by quaker (Initiate) on May 13, 2008 at 22:26 UTC
    1. create sub start_document in your handler package. It can be empty.
    2. create sub set_document_locator.
    sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; return bless $self, $class; } sub start_document { # Empty. But MUST exist. } sub set_document_locator { my ($self, $params) = @_; $self->{'_parser'} = $params->{'Locator'}; } sub start_element { my $self = shift; print Dumper($self->{'_parser'}->location()); }