Loading ...
Sorry, an error occurred while loading the content.

3114Arrays of arrays

Expand Messages
  • teden
    Nov 6, 2003
      Folks,

      A little while back, I posted a question about processing arrays of
      arrays, and got some great help from Duncan Cameron. The suggested
      solution was something like this:

      my $som = SOAP::Deserializer->deserialize($xml);
      # Iterate through all child elements of <person>
      for (my $i = 1; my $a = $som->dataof("//person/[$i]"); $i++) {
      ...
      for (my $j = 1; my $b = $som->dataof("//person/[$i]/[$j]"); $j++) {
      ...
      }
      }

      However, I found that this was sloooooow since every loop through you
      had to perform a $som->dataof which was exceedingly expensive. I
      rewrote it like so:

      my $som = SOAP::Deserializer->deserialize($xml);
      my $i = 0;
      foreach my $a ($som->dataof("//person/*")) {
      $i++;
      my $j = 0;
      foreach my $b ($som->dataof("//person/[$i]/*")) {
      $j++;
      ...
      }
      }

      and it runs significantly faster. Just thought you all might like to
      know...

      Thom Eden
    • Show all 2 messages in this topic