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

Re: [soaplite] SOAP::SOM question

Expand Messages
  • Thom Eden
    After messing around with this enough, I think I found the solution, though I leave it to people much smarter than me to tell me if I am terribly inefficient.
    Message 1 of 3 , Aug 28, 2003
    • 0 Attachment
      After messing around with this enough, I think I found the solution, though I leave it to people much smarter than me to tell me if I am terribly inefficient. Here's my code snippet which works:

      <VARIABLES>
      <Var vName="Test_1">Bloody wanker</Var>
      <Var vName="Test_2">3.1415</Var>
      </VARIABLES>

      @elements = qw(VARIABLES);
      foreach my $element(@elements) {
      print "$element:\n";
      foreach my $e($som->dataof('//'.$element.'/Var')) {
      print "Variable Name = ".$e->attr->{'vName'}."\n";
      print "Variable Value = ".$e->value."\n";
      }
      }

      Thanks for all the support...

      Thom Eden
      ---------- Original Message ----------------------------------
      From: "Thom Eden" <the@...>
      Reply-To: <the@...>
      Date: Thu, 28 Aug 2003 16:15:23 -0400

      >Ok, so $som->valuof() can be used to iterate over an array. What if you need an attribute of the elements in the array? The only way to get an attribute is through $som->dataof() which returns a hash, so if you have a repeating element, you lose the data. Here is my data:
      >
      ><VARIABLES>
      > <Var vName="Test_1">Bloody wanker</Var>
      > <Var vName="Test_2">3.1415</Var>
      ></VARIABLES>
      >
      >
      >---------- Original Message ----------------------------------
      >From: "Byrne Reese" <byrne@...>
      >Date: Wed, 27 Aug 2003 18:36:16 -0700 (PDT)
      >
      >>http://www.majordojo.com/soaplite/
      >>
      >>But specifically:
      >>http://www.majordojo.com/archives/000042.html#000042
      >>
      >>>
      >>>
      >>>
      >>>
      >>> Folks,
      >>>
      >>> I am building a web service in SOAP::Lite. Part of the results
      >>> returned is a set of repeating elements e.g.
      >>>
      >>> >;response
      >>> >;statusMsg;/statusMsg
      >>> >;statusMsg;/statusMsg
      >>> >;statusMsg;/statusMsg
      >>>
      >>> >;output
      >>> >;result;/result
      >>> >;/output
      >>> >;/response
      >>>
      >>> On my client side, with trace on, I see the whole XML document, with
      >>> all of the elements listed. However, when I try to process the
      >>> results in my client, SOAP::Lite is pushing this into a nested hash
      >>> structure. Hence, when I go to get my statusMsg's, I am left with
      >>> only the last one, the first two are lost. Any kind of repeating
      >>> element does the same thing.
      >>>
      >>> Is there any way around this?
      >>>
      >>> Any help is greatly appreciated...
      >>>
      >>> Thom Eden
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>> Yahoo! Groups Sponsor
      >>>
      >>>
      >>> ADVERTISEMENT
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>>
      >>> To unsubscribe from this group, send an email to:
      >>> soaplite-unsubscribe@yahoogroups.com
      >>>
      >>>
      >>>
      >>>
      >>>
      >>> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
      >>>
      >>>
      >>>
      >>>
      >>>
      >>
      >>
      >>^byrne :/
      >>
      >
      >
      >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.