in reply to Recursive XML navigation XML::Twig help!
What I want, is to parse <node id="0"> and purge before moving onto the next node
what I have at the moment, which is running out of memory is
#! /usr/bin/perl use strict; use warnings; use XML::Twig; my $file = $ARGV[0]; my $twig= new XML::Twig( TwigRoots=>{geography=>1}, TwigHandlers=> { 'node' =>\&geog_node } ); $twig->parsefile($file); sub geog_node { my($twig, $section) = @_; if($section->att('hidden') eq '0') { print"Data for node: \n"; print"\tID:\t",$section->att('id'),"\n"; print "\tDesc:\t",$section->first_child('description')->text," +\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Recursive XML navigation XML::Twig help!
by mirod (Canon) on Oct 02, 2006 at 08:21 UTC |