Hm. Ok. I am a step further. But why don't I get the right values with this:
my $t= XML::Twig->new( twig_handlers => { 'league/id' =>sub +{ $leagueId = $_[1]->text;}, 'event/startDateTime' + =>sub{ $date = $_[1]->text;}, 'event/homeTeam/name' + =>sub{ $home = $_[1]->text;}, 'event/awayTeam/name' + =>sub{ $away = $_[1]->text;}, 'event/periods/period/number' + =>sub{ $period = $_[1]->text;}, 'event/periods/period/description' + =>sub{ $perDescr = $_[1]->text;}, 'event/periods/period/maxBetAmount/moneyLine +' =>sub{ $maxBetML = $_[1]->text;}, 'event/periods/period/moneyLine/homePrice' + =>sub{ $homePrice = $_[1]->text;}, 'event/periods/period/moneyLine/drawPrice' + =>sub{ $drawPrice = $_[1]->text;}, 'event/periods/period/moneyLine/awayPrice' + =>sub{ $awayPrice = $_[1]->text; print "\nMoney,", $lea +gueId, " ", $date, " ", $home, " ", $away, " ", $period, +" ", $perDescr, " ", $maxBetML, " ", $homePrice, " ", $dr +awPrice, " ", $awayPrice; } );
Your code gives me all fixtures. I am now looking for all moneyline-odds for these fixtures. In the XML there are different periods for a game (mostly match and 1st half). Not all of the periods are given for all matches. And if there is a period there does not have to be a moneyline.
So I tried the magic workaround with other data. My code tries to store the other relevant data in scalars and then put all together with the last handler-line. But the data is mixed up.
In reply to Re^8: How to parse this hash? XML question (Twig example)
by Trace On
in thread How to parse this hash? And how to describe my probem?
by Trace On
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |