in reply to Not able to filter the records, which has state CA is first <StateorProvince> tag

#!/usr/bin/perl use 5.016; use strict; use warnings; use XML::Twig; open (my $OFILE, '>:utf8', './bits.xml') or die "Could not open [./bits.xml]:\n$!\n$^E"; my $t = XML::Twig->new( twig_roots => { 'Listing' => \&listing, }, pretty_print => 'indented', ); $t->parse(*DATA); sub listing { my ($t,$e) = @_; my $addr = $e->first_child('Address'); my $state = $addr->first_child('State')->text; print $state."\n"; if ($state eq 'CA'){ $t->flush($OFILE); } else { $t->purge; } }
poj
  • Comment on Re: Not able to filter the records, which has state CA is first <StateorProvince> tag
  • Download Code