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

RE: [soaplite] Non-unique values

Expand Messages
  • Johnson, Keith
    Thanks Paul that did it! Thanks for the assistance. Keith ... From: Paul Kulchenko [mailto:paulclinger@yahoo.com] Sent: Tuesday, March 06, 2001 8:50 PM To:
    Message 1 of 3 , Mar 8 5:24 AM
    • 0 Attachment
      RE: [soaplite] Non-unique values

      Thanks Paul that did it!  Thanks for the assistance.


      Keith

      -----Original Message-----
      From: Paul Kulchenko [mailto:paulclinger@...]
      Sent: Tuesday, March 06, 2001 8:50 PM
      To: soaplite@yahoogroups.com
      Subject: Re: [soaplite] Non-unique values


      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/

      ------------------------ Yahoo! Groups Sponsor ---------------------~-~>
      Find software faster. Search more than 20,000
      software solutions on KnowledgeStorm. Register
      now and get started.
      http://us.click.yahoo.com/._XvHB/uMSCAA/zf4EAA/WNqXlB/TM
      ---------------------------------------------------------------------_->

      To unsubscribe from this group, send an email to:
      soaplite-unsubscribe@yahoogroups.com

       

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

    Your message has been successfully submitted and would be delivered to recipients shortly.