And it seems to be solved, but sometimes there is the concatenation of different values. I can't understand where, in my code, i have to reset my variable. I tried in the start handler and in the end handler but after the reset the variable in empty. I have to use this low level module, because i don't have to much time for modify all the code. B/R#!/usr/bin/perl use XML::Parser; @files = <$plrepository/*.xml>; foreach $xmlfile (@files) { #something is omitted $p2 = new XML::Parser(Handlers => {Start => \&handle_start, End => \&handle_end, Char => \&handle_char}); $p2->parsefile($xmlfile); } sub handle_start { my ($pkg,$element,%attr) = @_; $current_element = $element; if ( $element =~ /Header/i ) { $Number=$attr{Number}; open (OUT, ">$outputfile") or die "No file"; } #something is omitted } sub handle_end { my ($pkg,$element,%attr) = @_; if ( $element =~ /Header/i ) { print OUT $Number,"$separator\n"; print "\tNumber ". $Number . "\n"; close (OUT); } #something is omitted } sub handle_char { my $text = $_[1]; if ( $current_element =~ /^Number$/i ) { # THE BUFFER ($text !~ /^\s*$/) && ($Number = $Number.$text); # THE BUFFER } #something is omitted }
In reply to Re^2: problem with XML::Parser
by Paulux
in thread problem with XML::Parser
by Paulux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |