in reply to Re^4: How to parse this hash? And how to describe my probem?
in thread How to parse this hash? And how to describe my probem?
#!/usr/bin/perl use strict; use warnings; use XML::Twig; my $cur_league='UNKNOWN'; my $t= XML::Twig->new( twig_handlers => { 'league/id' => sub{ $cur_league = $_[1]->te +xt}, 'event/startDateTime'=>sub{ print "$cur_lea +gue,",$_[1]->text,","; }, 'event/homeTeam/name'=>sub{ print $_[1]->te +xt }, 'event/awayTeam/name'=>sub{ print ",",$_[1] +->text,"\n"; } #add more handlers as needed.. } ); $t->parsefile('trace_on.xml'); __OUTPUT__ 1739,2015-06-24T11:59:00Z,Union Mar del Plata,C. Cordoba Santiago 1739,2015-06-08T20:59:00Z,Douglas Haig,Santamarina Tandil 1740,2015-06-30T16:59:00Z,Arsenal de Sarandi,Crucero del Norte 1740,2015-06-14T11:59:00Z,Aldosivi Mar del Plata,Rosario Central 1740,2015-06-14T11:59:00Z,Arsenal de Sarandi,Gimnasia La Plata 1740,2015-06-14T11:59:00Z,Atletico Huracan,Defensa y Justicia 1740,2015-06-14T11:59:00Z,Belgrano de Cordoba,Argentinos Juniors 1740,2015-06-14T11:59:00Z,Estudiantes La Plata,San Martin San Juan 1740,2015-06-14T11:59:00Z,Godoy Cruz Antonio Tomba,Crucero del Norte 1740,2015-06-14T11:59:00Z,Independiente,Olimpo Bahia Blanca 1740,2015-06-14T11:59:00Z,Lanus,Atletico Rafaela 1740,2015-06-14T11:59:00Z,Newells Old Boys,Racing Club 1740,2015-06-14T11:59:00Z,Nueva Chicago BA,Colon de Santa Fe 1740,2015-06-14T11:59:00Z,Quilmes,Banfield 1740,2015-06-14T11:59:00Z,River Plate,Temperley 1740,2015-06-14T11:59:00Z,Sarmiento,Boca Juniors 1740,2015-06-14T11:59:00Z,Union Santa Fe,San Lorenzo 1740,2015-06-14T11:59:00Z,Velez Sarsfield,Club Atletico Tigre 1740,2015-06-08T20:59:00Z,Club Atletico Tigre,Aldosivi Mar del Plata 1740,2015-06-08T23:09:00Z,Defensa y Justicia,Estudiantes La Plata 1756,2015-06-08T10:29:00Z,Bulleen Lions,Brunswick City
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: How to parse this hash? XML question (Twig example)
by Trace On (Novice) on Jun 09, 2015 at 07:42 UTC | |
by Discipulus (Canon) on Jun 09, 2015 at 08:10 UTC | |
by Trace On (Novice) on Jun 09, 2015 at 11:17 UTC | |
by Discipulus (Canon) on Jun 09, 2015 at 12:05 UTC | |
by Anonymous Monk on Jun 09, 2015 at 07:54 UTC |