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

4157dataof() use with index

Expand Messages
  • Martin Naskovski
    Nov 5, 2004
    • 0 Attachment
      Hi - I have this code:

      $som->match('/Envelope/Body/[1]');
      my @evtList;

      my $idx = 1;
      while ( defined $som->dataof("[$idx]") ) {
      ...
      my $eventXML = $som->dataof("[$idx]/event");
      $event->set_eventName($eventXML->attr()->{eventName});
      $event->set_eventID($eventXML->attr()->{eventID});
      ...
      }

      Which basically takes MANY <regAPI> </regAPI>, elements in my XML stream,
      and the $idx is used to access each <regAPI> / </regAPI> pair as an array,
      by using 'dataof()' (or valueof() if you wish).

      The <regAPI> / <.regAPI> contains this:

      <regAPI>
      <event .... />
      </regAPI>

      My problem is, when I have a SOAP call which returns JUST ONE <regAPI> /
      </regAPI> , the above code does NOT work, so in order to get the 'event'
      part, I have to do:

      ->dataof('//event');

      everytime I have a SINGLE <regAPI> pair.

      Why cant I just process even a SINGLE element as a list through my while
      loop, with only a signle iteration through it, and return a LIST with ONE
      element in it?

      Am I missing something, or is this not possible wit hthe SOAP::Lite xpath
      language?

      Thanks.
    • Show all 2 messages in this topic