I have been spending hours trying to parse a SOAP response that I have no control over. I have tried numerous methods I found on SO with no luck.
Here is the response body I get from edge browser:
<?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns1:gXMLQueryResponse xmlns:ns1="urn:com-photomask-feconnect-IFeConnect" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:string"><?xml version = '1.0' encoding = 'UTF-8'?> <ROWSET> <ROW num="1"> <CUSTOMER_NAME>HITACHI</CUSTOMER_NAME> </ROW> </ROWSET> </return> </ns1:gXMLQueryResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> I'm trying to get the CUSTOMER_NAME value.
Here is the code I am using:
$client = new SoapClient($urla, array('trace' => 1)); try { $result = $client->__soapCall("gXMLQuery", $params); $response = ($client->__getLastResponse()); $xml = simplexml_load_string($response); $rows = $xml->children('SOAP-ENV', true)->Body->children('ns1', true)->gXMLQueryResponse->return->ROWSET->ROW; foreach ($rows as $row) { $customer = $row->CUSTOMER_NAME; echo $customer; } } catch (SoapFault $e) { }