Paulux has asked for the wisdom of the Perl Monks concerning the following question:
on more or less 29000 XML files. Sometimes happens that the text between the tags are truncated (i.e. -912 instead of 120A33-912). How can it be possible? there's a limitation on XML::Parser? Has someone had the same problem? 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 ) { ($text !~ /^\s*$/) && ($Number = $text); } #something is omitted }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem with XML::Parser
by mirod (Canon) on Jun 18, 2009 at 13:22 UTC | |
by Paulux (Acolyte) on Jun 19, 2009 at 07:27 UTC | |
by mirod (Canon) on Jun 19, 2009 at 07:58 UTC | |
|
Re: problem with XML::Parser
by Jenda (Abbot) on Jun 19, 2009 at 01:12 UTC | |
by Paulux (Acolyte) on Sep 30, 2009 at 07:44 UTC |