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

Re: [soaplite] Problems with Arrays only returning 1 element

Expand Messages
  • Paul Kulchenko
    Hi Andy, ... It doesn t suppose to work this way; match() remembers matched dataset internally and returns SOAP::SOM object, so that subsequent dataof/valueof
    Message 1 of 3 , Dec 20, 2002
    • 0 Attachment
      Hi Andy,

      > It doesn't throw any errors, but I only ever get catref0 returned
      > with
      > the correct value. I never get the second element. The same is true
      It doesn't suppose to work this way; match() remembers matched
      dataset internally and returns SOAP::SOM object, so that subsequent
      dataof/valueof calls can use this value. Regardless of the context
      (list/scalar) result is always the same: one object. That's why
      scalar(@elements) always returns '1', even though there are more
      elements.

      You can change your code to smth like this:

      @elements = $product->match("//categoryElements/category")->valueof;

      -- OR --

      @elements = $product->valueof("//categoryElements/category");

      and remove valueof() from:

      $buff .= "catref$k\t" . $elements[$k] . "\t";

      dataof/valueof('something') are shortcuts for
      match('something')>dataof/valueof(). Hope that helps.

      Best wishes, Paul.

      --- Andy Kelk <andy@...> wrote:
      > Hi,
      >
      > I have a document which has a snipped structured something like
      > this:
      >
      > <categoryElements
      > xmlns:namesp1="http://schemas.xmlsoap.org/soap/encoding/"
      > xsi:type="namesp1:categoryArray" namesp1:arrayType="xsd:string[2]">
      > <category xsi:type="xsd:string">@1020</category>
      > <category xsi:type="xsd:string">@1006</category>
      > </categoryElements>
      >
      >
      > The code I want to use to get this info is like this:
      >
      > @elements = $product->match("//categoryElements/category");
      > $tot = scalar(@elements);
      > for ($k = 0; $k < $tot; $k++)
      > {
      > $buff .= "catref$k\t" . $elements[$k]->valueof() . "\t";
      > }
      >
      > It doesn't throw any errors, but I only ever get catref0 returned
      > with
      > the correct value. I never get the second element. The same is true
      > of
      > my other arrays.
      > I have only thrown myself into SOAP::Lite recently so I may have
      > made an
      > elementary mistake (I probably have). But I have searched this
      > group and
      > many others to try and find a solution and feel I have hit a brick
      > wall.
      > Any help would be much appreciated.
      >
      > Thanks
      >
      > Andy
      >
      >
      > --
      > Andy Kelk
      > Head of Integration, Venda
      > andy@...
      >
      > ------------------------ 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! Mail Plus - Powerful. Affordable. Sign up now.
      http://mailplus.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.