Can anyone help me change Handlers in XML::Parser?
Code excerpt is as follows:
#!/usr/bin/perl -w use strict; use XML::Parser; open (FILEA, "File.txt"); my $parser = XML::Parser->new(); $parser->setHandlers(Start => \&handle_start, Char => \&handle_char, End => \&handle_end1, Final => \&final1); $parser-parsefile('File2.txt'); my $char_array_ref; my @end_array; sub handle_start{ my $e = shift; my $start_element = shift; if ($start_element eq 'coordinates'){print "hello.\n"; $parser->setHandlers(Char => \&coord); } } sub handle_char{ my $e = shift; print "HELLO There\n."; } sub coord{ my $e = shift; print "hello again.\n"; }
Use of print commands serve as a test to see which subroutines are called on Char events.
I never see "hello again" printed to the screen.
The Expat documentation suggests that you can change a handler conditionally as I am trying to do.
But I cannot seem to get it to work.
Can anyone point me in the right direction?
I would be very much obliged.
Thanks
In reply to change setHandlers XML::Parser by etlamar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |