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

iterate through results

Expand Messages
  • Doug Fulton
    I need to process results looking like: 1 a 2 b
    Message 1 of 3 , Mar 27, 2002
    • 0 Attachment
      I need to process results looking like:

      <jobs>
      <job>
      <jobID>1</jobID>
      <jobDetail>a</jobDetail >
      </job>
      <job>
      <jobID>2</jobID>
      < jobDetail >b</jobDetail >
      </job>
      ....
      </jobs>

      I don't know how many <job> elements I will encounter in advance.
      Recommended method?

      Thanks,
      Doug
    • Doug Fulton
      Lee, It works perfectly. And since I know exactly the name and number of nested elements, I can simplify it: my @jobs = $som- ( //job ); my $cn =
      Message 2 of 3 , Mar 27, 2002
      • 0 Attachment
        Lee,

        It works perfectly. And since I know exactly the name and number of
        nested elements, I can simplify it:

        my @jobs = $som->('//job');
        my $cn = scalar(@jobs);
        for (my $k=0; $k < $cn; $k++) {
        &do_the_job $jobs[$k]->{'jobID'} $jobs[$k]->{'jobDetail'};
        }

        You are obviously learning well. Thanks much for sharing!

        Cheers,
        Doug

        On Wednesday, March 27, 2002, at 05:31 PM, Lee Carmichael wrote:

        > Hello Doug,
        >
        > I just figured this out today. Using the
        > SOAP::SOM->result() didn't yield my expected behavior.
        > But using the valueof() with the parameter in either
        > array or hash context did.
        >
        > I'm not sure what method your using in retrieving the
        > data but I give a quick example with the SOM object
        > being, $som. Here is what I would try using an array,
        > you can do the same cool stuff with a hash:
        >
        > ## assuming that this is
        > ## the call, could be whatever
        > my $som = $soap->GetJobs($data);
        >
        > ## not checking the $som->fault
        > ## which should be done.
        >
        > # to get an array do
        > my @jobs = $som->('//job');
        > my $cn = scalar(@jobs);
        >
        > print "Found [$cn] Jobs\n";
        > for(my $k = 0; $k < $cn; $k++) {
        > foreach (keys(%{$jobs[$k]})) {
        > print "Found [$_] with value
        > [$jobs[$k]->{$_}\n";
        > }
        > }
        >
        > That should give you what you want. (please check for
        > typos since I'm in a damn web browser editor thing...)
        >
        > Let me know if works or doesn't, I'm really learning
        > this stuff.
        >
        > Good Luck,
        >
        > Lee
        >
        >
        > --- Doug Fulton <dfulton@...> wrote:
        >> I need to process results looking like:
        >>
        >> <jobs>
        >> <job>
        >> <jobID>1</jobID>
        >> <jobDetail>a</jobDetail >
        >> </job>
        >> <job>
        >> <jobID>2</jobID>
        >> < jobDetail >b</jobDetail >
        >> </job>
        >> ....
        >> </jobs>
        >>
        >> I don't know how many <job> elements I will
        >> encounter in advance.
        >> Recommended method?
        >>
        >> Thanks,
        >> Doug
        >>
        >>
        >>
        >>
        >
        >
        > __________________________________________________
        > Do You Yahoo!?
        > Yahoo! Movies - coverage of the 74th Academy AwardsÆ
        > http://movies.yahoo.com/
        >
      • Paul Kulchenko
        Hi, Doug! That s correct, however there is more perlish syntax: print $_- { jobID }, , $_- { jobDetail }, n for $som- ( //job ); ;) Best wishes, Paul.
        Message 3 of 3 , Mar 27, 2002
        • 0 Attachment
          Hi, Doug!

          That's correct, however there is more "perlish" syntax:

          print $_->{'jobID'}, " ", $_->{'jobDetail'}, "\n"
          for $som->('//job');

          ;)

          Best wishes, Paul.

          --- Doug Fulton <dfulton@...> wrote:
          > Lee,
          >
          > It works perfectly. And since I know exactly the name and number
          > of
          > nested elements, I can simplify it:
          >
          > my @jobs = $som->('//job');
          > my $cn = scalar(@jobs);
          > for (my $k=0; $k < $cn; $k++) {
          > &do_the_job $jobs[$k]->{'jobID'} $jobs[$k]->{'jobDetail'};
          > }
          >
          > You are obviously learning well. Thanks much for sharing!
          >
          > Cheers,
          > Doug
          >
          > On Wednesday, March 27, 2002, at 05:31 PM, Lee Carmichael wrote:
          >
          > > Hello Doug,
          > >
          > > I just figured this out today. Using the
          > > SOAP::SOM->result() didn't yield my expected behavior.
          > > But using the valueof() with the parameter in either
          > > array or hash context did.
          > >
          > > I'm not sure what method your using in retrieving the
          > > data but I give a quick example with the SOM object
          > > being, $som. Here is what I would try using an array,
          > > you can do the same cool stuff with a hash:
          > >
          > > ## assuming that this is
          > > ## the call, could be whatever
          > > my $som = $soap->GetJobs($data);
          > >
          > > ## not checking the $som->fault
          > > ## which should be done.
          > >
          > > # to get an array do
          > > my @jobs = $som->('//job');
          > > my $cn = scalar(@jobs);
          > >
          > > print "Found [$cn] Jobs\n";
          > > for(my $k = 0; $k < $cn; $k++) {
          > > foreach (keys(%{$jobs[$k]})) {
          > > print "Found [$_] with value
          > > [$jobs[$k]->{$_}\n";
          > > }
          > > }
          > >
          > > That should give you what you want. (please check for
          > > typos since I'm in a damn web browser editor thing...)
          > >
          > > Let me know if works or doesn't, I'm really learning
          > > this stuff.
          > >
          > > Good Luck,
          > >
          > > Lee
          > >
          > >
          > > --- Doug Fulton <dfulton@...> wrote:
          > >> I need to process results looking like:
          > >>
          > >> <jobs>
          > >> <job>
          > >> <jobID>1</jobID>
          > >> <jobDetail>a</jobDetail >
          > >> </job>
          > >> <job>
          > >> <jobID>2</jobID>
          > >> < jobDetail >b</jobDetail >
          > >> </job>
          > >> ....
          > >> </jobs>
          > >>
          > >> I don't know how many <job> elements I will
          > >> encounter in advance.
          > >> Recommended method?
          > >>
          > >> Thanks,
          > >> Doug
          > >>
          > >>
          > >>
          > >>
          > >
          > >
          > > __________________________________________________
          > > Do You Yahoo!?
          > > Yahoo! Movies - coverage of the 74th Academy Awards�
          > > http://movies.yahoo.com/
          > >
          >
          >
          >
          > ------------------------ Yahoo! Groups Sponsor
          >
          > 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/
          >
          >


          __________________________________________________
          Do You Yahoo!?
          Yahoo! Movies - coverage of the 74th Academy Awards�
          http://movies.yahoo.com/
        Your message has been successfully submitted and would be delivered to recipients shortly.