[SOAP] Re: how to grab a list of objects from a soap response

[email protected]
Newsgroups php.soap
Message-ID <[email protected]>
Quoting Milo van der Linden <[email protected]> (Seg 03 Set 2007 16:02:00 WEST):

> I also prefer not to parse the string for future compatibility with  
> the php soap library..
>
> I am one step further;
>
> I now try:
>
> Which gives me:
> string(469)  
> "<Projects><Project><ID>1</ID><Name>LOGIS_2007-1</Name></Project><Project><ID>2</ID><Name>LOGIS_2007-2</Name></Project><Project><ID>3</ID><Name>LOGIS_2007-3-1</Name></Project><Project><ID>4</ID><Name>LOGIS_2007-4</Name></Project><Project><ID>5</ID><Name>LOGIS_2007-5</Name></Project><Project><ID>6</ID><Name>LOGIS_2007-6</Name></Project><Project><ID>7</ID><Name>MWI_TEST_LOCATIEVELD</Name></Project><Project><ID>8</ID><Name>MWI_TEST_LOCATIE_2</Name></Project></Projects>"
>
> So at least the string only contains a Projects collection now.
>
> I also noticed that thw WDSL definition does not contain a  
> description of the content of the Response, it simply states "any"

Viewing this thread I the WSDL just return the XML with the result. So  
you have to parse the result. IMO you should use simplexml to parse  
the xml string. It's very simple to use.

$xml = new SimpleXMLElement($your_xml_string);

foreach ($xml->Project as $proj) {
   echo $proj->ID . "\n";
   echo $proj->Name . "\n";
   echo "-------------\n";
}

-- 
Carlos Pires
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.