in reply to Re: Using XML Twig to summarize a large file
in thread Using XML Twig to summarize a large file
Each of these ItemMasters has around eight children and the children have anywhere from one to twenty-four children. Because the children are not uniform this is giving me headaches. Here's my first revision<is:ItemMaster> <is:ItemMasterHeader> <oi:ItemID agencyRole="Product_Number">some_number</oi:ItemID> <oi:ItemID agencyRole="Prefix_Number">some_number</oi:ItemID> <oi:ItemID agencyRole="Stock_Number">some_number</oi:ItemID> <oi:ManufacturerItemID>some_manufacturer_ID</oi:ManufacturerID> <is:Classification type="Group"></is:Classification> <is:Classification></is:Classification>
Now when I print I get nothing. I tried a test run and it seems like the handlers are not getting called at all.#!/bin/perl use XML::Twig; %Items=(); my $twig=XML::Twig->new( twig_handlers => {populate=> sub { while (<>) { if (%Items !~ m/"<us:"|"<oa:"(.*)/) { $Items{$1} =1} else {$Items{$2} =($Items{$1}+(/$1/)) } }; #If element is not in the hash, adds it }, #If element is in the hash, adds the number of matches div => sub { $_[0]->purge; }, # free memory }, ); $twig->parsefile( '500syncItemMaster.xml'); # build it $twig->purge; # clear end of document from memory print %Items; # output the twig
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Using XML Twig to summarize a large file
by mirod (Canon) on Nov 07, 2007 at 16:10 UTC | |
by Mr.Churka (Sexton) on Nov 07, 2007 at 17:03 UTC | |
by mirod (Canon) on Nov 07, 2007 at 17:40 UTC |