quickskate has asked for the wisdom of the Perl Monks concerning the following question:
and my XML file#!/usr/bin/perl #use strict; use XML::Simple; use Data::Dumper; my $filename = 'C:/perlfiles/request1.xml'; my $library = XMLin($filename, ForceArray => 1 ); #print Dumper ($library) ; my $count=0; foreach my $key ( keys %{$library->{place}} ) { if ($key eq 'SouthAfrica') { foreach my $loopback ( @{$library->{place}{$key}{dataName}} ) { if ($loopback eq 'English') { print "key = $key; loopback = $loopback\n" ; } } } }
<?xml version="1.0" encoding="utf-8" ?> <request> <place> <country>SouthAfrica</country> <sports>cricket</sports> <sports>rugby</sports> <dataName> <language>English</language> <sampling>16000</sampling> <sampling>11025</sampling> </dataName> <dataName> <language>Africans</language> <sampling>16000</sampling> </dataName> </place> </request>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem traversing nested nodes XML::Simple
by mscharrer (Hermit) on Apr 29, 2008 at 15:05 UTC | |
|
Re: Problem traversing nested nodes XML::Simple
by toolic (Bishop) on Apr 29, 2008 at 15:21 UTC | |
|
Re: Problem traversing nested nodes XML::Simple
by dragonchild (Archbishop) on Apr 29, 2008 at 15:04 UTC | |
|
Re: Problem traversing nested nodes XML::Simple
by Jenda (Abbot) on Apr 30, 2008 at 19:09 UTC |