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

97Re: [soaplite] Non-unique values

Expand Messages
  • Paul Kulchenko
    Mar 6, 2001
    • 0 Attachment
      Hi, Keith!

      YOu almost did it :)). valueof() as well as other functions returns
      nodeset in array context and first node in scalar context. All that
      you need to do is put it in foreach or assign to array:

      my @addressOptions = $soap->SendOrder($data)
      ->valueof('//addressOption');

      foreach (@addressOptions) {
      print $_->{Description};
      }

      -- OR --

      foreach ($soap->SendOrder($data)->valueof('//addressOption')) {
      print $_->{Description};
      print $_->{Name};
      .... etc.
      }

      That should be it. Let me know if you need anything else.

      Best wishes, Paul.

      --- "Johnson, Keith" <kjohnson@...> wrote:
      > Has anyone run across a scenario where you need to parse out
      > non-unique
      > named XML elements such as <addressOption> listed below. When I
      > parse the
      > hash that is returned only the last <addressOption> is available.
      > Any
      > thoughts on how to be able to parse or loop through all of the
      > available
      > elements ?
      >
      > XML Document Returned from SOAP API Call.
      >
      > <addressOptionList>
      > <addressOption>
      > <Description>Home</Description>
      > <Name>Frank Smith</Name>
      > <Address1>12 Maple Avenue</Address1>
      > <Address2>Apt. 12</Address2>
      > <City>Fantasy Island</City>
      > <State>IL</State>
      > <ZipCode>60750</ZipCode>
      > </addressOption>
      > <addressOption>
      > <description>Business</Description>
      > <name>ABC Inc</Name>
      > <address1>12 Maple Avenue</Address1>
      > <address2>Att: Frank Smith</Address2>
      > <city>Fantasy Island</City>
      > <state>IL</State>
      > <zipCode>60750</ZipCode>
      > </addressOption>
      > </addressOptionList>
      >
      > $data=SOAP::Data
      > ->encodingStyle('http://xml.apache.org/xml-soap/literalxml')
      > ->name('SendOrder' => \%param );
      >
      > $hash = $soap->SendOrder($data)->valueof('//addressOptionList');
      > %hash2 = %{$hash->{'addressOption'}};
      >
      > $description= $hash2{'description'};
      > $name = $hash2{'name'};
      > $address1 = $hash2{'address1'};
      > $address2 = $hash2{'address2'};
      > $city = $hash2{'city'};
      > $state = $hash2{'state'};
      > $zipCode = $hash2{'zipCode'};
      >
      >
      >
      > Thanks,
      > Keith
      >
      >


      __________________________________________________
      Do You Yahoo!?
      Get email at your own domain with Yahoo! Mail.
      http://personal.mail.yahoo.com/
    • Show all 3 messages in this topic