in reply to xml::twig and node names
textsub readxml{ $xmlfile = shift; my $twig= new XML::Twig(twig_handlers => { '/kvdt' => \&fall }); + $twig->parsefile($xmlfile); } sub fall{ my( $twig, $element)= @_; my @scheine = $element->get_xpath('.//*'); foreach my $schein (@scheine){ my $fk = $schein->name; if ($schein->{att}->{USE}){($schein->{att}->{USE} =~ /EDV/)?(n +ext):();} if ($fk =~ /fk....\b/){ my $key = substr($fk,2,4); $data{xml}{$key}++; } } }
is there a way to make this faster using ::twig ?sub readxml{ $xmlfile = shift; open(XML, $xmlfile); while(<XML>){ chomp(); my $line = $_; my @bla; ($line =~ /USE="EDV"/)?(next):(); if ($line =~ /<fk....[^_]/){ @bla = split(/<fk/,$line); my $key = substr($bla[1],0,4); #30 $data{xml}{$key}++; } } close(XML); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: xml::twig and node names
by m0ve (Scribe) on Sep 21, 2007 at 08:33 UTC |