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

6110Access to array

Expand Messages
  • Andrei Ivanov
    Feb 11, 2008
    • 0 Attachment
      Hi, how can I get access to the SOAP::Data structure with brackets []

      I have an array of items such:

      <namesp1:findrecResponse xmlns:namesp1="meetup">
      <result xsi:type="namesp2:items">
      <item xsi:type="namesp2:item" SOAP-ENC:arrayType="xsd:ur-type[13]">
      <phone xsi:type="xsd:string">5551256</phone>
      ...
      <radius xsi:type="xsd:float">100</ends>
      </item>
      </result>

      I need to sort produced SOAP::Data structure by the radius at the
      server side before send result to the client:

      foreach $u (keys %h) {
      ...
      @r = (
      SOAP::Data->name('phone')->type('string')-
      >value($serialize[2])
      ...
      SOAP::Data->name('radius')->type('float')-
      >value($serialize[16])
      );
      push @ra, SOAP::Data->name('item'=>[@r])-
      >type('item');

      }
      # sort array
      my @rb = sort { mysortfunc($a) <=> mysortfunc($b} @ra;
      return SOAP::Data->name("result" => \SOAP::Data->value(
      SOAP::Data->name("item" => @ra)->type("item"))
      )->type("items");

      ...


      sub mysortfunc {
      my @r = shift;
      ...
      return @r;
      }

      Beacuse I need to use brackets [@r] to produce valid structure, but I
      can not get access to the item.
      First is an array, then SOAP::Data hash, then array, then SOAP::Data
      hash and then just arrays.