I found several solutions for converting SOAP response into a object, but none of them work. I get my soap response as an xml string, e.g.:
$response = '
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://xxx.company.com" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:DataResponse>
<DataReturn xsi:type="ns1:OutXT">
<Errors SOAP-ENC:arrayType="ns1:Errors[12]" xsi:type="ns1:ErrorsArray">
<item xsi:type="ns1:Errors">
<ErrorItem xsi:type="xsd:string">Access</ErrorItem>
<DescErrors xsi:type="xsd:string">User not found</DescErrors>
</item>
<item xsi:type="ns1:Errors">
<ErrorItem xsi:type="xsd:string">Client check</ErrorItem>
<DescErrors xsi:type="xsd:string">Report 85 completed</DescErrors>
</item>
</Errors>
<ClientCategory xsi:type="xsd:string">A</ClientCategory>
<Premium xsi:type="ns1:Premium">
<Price xsi:type="xsd:int">2509</Price>
<Coef xsi:type="xsd:float">4.558</Coef>
<Discount xsi:type="xsd:int">35</Discount>
</Premium>
<Sample xsi:type="xsd:int">0</Sample>
<Status xsi:type="xsd:string">OK</Status>
</DataReturn>
</ns1:DataResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
And I need to get rid of all the namespaces including the colon and all the attributes so the outcome in this case would be:
<Envelope>
<Body>
<DataResponse>
<DataReturn>
<Errors>
<item>
<ErrorItem>Access</ErrorItem>
<DescErrors>User not found</DescErrors>
</item>
<item>
<ErrorItem>Client check</ErrorItem>
<DescErrors>Report 85 completed</DescErrors>
</item>
</Errors>
<ClientCategory>A</ClientCategory>
<Premium>
<Price>2509</Price>
<Coef>4.558</Coef>
<Discount>35</Discount>
</Premium>
<Sample>0</Sample>
<Status>OK</Status>
</DataReturn>
</DataResponse>
</Body>
</Envelope>
I found some regular expression that allegedly does that job but it simply doesn't work either:
$response = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);