Read the contents of an xml

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Read the contents of an xml

Jigal Sanders
Hello everyone.

I use Zend_Soap_Client to comunicate with a webservice.

I have $response = $this->client->getlastResponse();
This gives me an xml file with the response. How can i read a node from this file?
How can I get the contents of the node <return>123</return>?

Thanks in advance

jsanders
Reply | Threaded
Open this post in threaded view
|

RE: Read the contents of an xml

DerMika

Hi,

 

If you use getLastResponse(), you will have a string in $response.

 

You have to load this string in a DOMDocument object. You can then either do $domdocument->getElementsByTagName(‘return’), or if it’s a more complex return document, you can create a DOMXpath object to query the DOMDocument. You can then use XPath to query for the node you need.

 

Another possibility is to use:

 

$response  = $myzendsoapclient->callMethod($parameters);

 

Now – if you use a classmap in the Zend_Soap_Client –$response will be an object as defined in the WSDL file of the soap server. Of course you need every complex object in the WSDL schema in your classmap.

 

If you don’t use a classmap, this will be a StdClass object. You should be able to navigate through this object like this:

$returnvalue = $response->someNode->return; (or wherever the return node is)

 

Regards,

Dieter

 

From: Jigal sanders [mailto:[hidden email]]
Sent: dinsdag 25 november 2008 13:37
To: [hidden email]
Subject: [fw-webservices] Read the contents of an xml

 

Hello everyone.

I use Zend_Soap_Client to comunicate with a webservice.

I have $response = $this->client->getlastResponse();
This gives me an xml file with the response. How can i read a node from this file?
How can I get the contents of the node <return>123</return>?

Thanks in advance

jsanders

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.175 / Virus Database: 270.9.9/1808 - Release Date: 24/11/2008 14:36