
satnamx
New User
Jul 31, 2012, 2:14 AM
Post #3 of 4
(2998 views)
|
|
Re: [rovf] Looping using XMLSimple
[In reply to]
|
Can't Post
|
|
Hi, Thanks for the observations. in my full test script, I did actually use strict option and exact ouptput is below: perl testXMLSimple.pl -------------Section 1------------------------ RTAG: closure47 UUID: Group000 {Group}[0]->{NAME}: null {Group}[0]->{GroupRef}[0]->{GID}: Canada {Group}[0]->{GroupRef}[1]->{GID}: United States {Group}[0]->{GID}: Group000 {Group}[0]->{TYPE}: SELLFIRM {Group}[0]->{Property}[0]->{VALUE}: GRP01 {Group}[0]->{Property}[0]->{VALUE}: Level {Group}[1]->{Property}[0]->{VALUE}: RGN01 ----------------Section 2 --------------------- {Group}[0]->{GID}: Group000 Can't use an undefined value as an ARRAY reference at testXMLSimple.pl line 51. Line 51 in the test script is: for ($j = 0; $j < scalar (@{$e->{Group}->{GroupRef}}); $j++) { #Loop through the 'Group' My obseravtion is that as a test, Im outputting the following with hardcoded index values: my $e; foreach $e (@{$data->{Response}}) { print "RTAG: ", $e->{RTAG}, "\n"; #closure47 print "UUID: ", $e->{UUID}, "\n"; print "{Group}[0]->{NAME}: ", $e->{Group}[0]->{NAME}, "\n"; #'null' print "{Group}[0]->{GroupRef}[0]->{GID}: ", $e->{Group}[0]->{GroupRef}[0]->{GID}, "\n"; #'Canada' print "{Group}[0]->{GroupRef}[1]->{GID}: ", $e->{Group}[0]->{GroupRef}[1]->{GID}, "\n"; #'United States' print "{Group}[0]->{GID}: ", $e->{Group}[0]->{GID}, "\n"; #'Group000' print "{Group}[0]->{TYPE}: ", $e->{Group}[0]->{TYPE}, "\n"; #'SELLFIRM' print "{Group}[0]->{Property}[0]->{VALUE}: ", $e->{Group}[0]->{Property}[0]->{VALUE}, "\n"; #'SELLFIRM' print "{Group}[0]->{Property}[0]->{VALUE}: ", $e->{Group}[0]->{Property}[0]->{NAME}, "\n"; #'Level' print "{Group}[1]->{Property}[0]->{VALUE}: ", $e->{Group}[1]->{Property}[0]->{VALUE}, "\n"; #'RGN01' } and they all come back with the correct data elements particlulary the line: print "{Group}[0]->{GroupRef}[0]->{GID}: ", $e->{Group}[0]->{GroupRef}[0]->{GID}, "\n"; #'Canada' which is what Im trying to obtain via my looping logic. Im reading up on the "internmediate perl" chapter on references to try and get a better grip on the solution but so far still struggling. Regards Satnam
|