I want to convert a soap xml response and store it in a database. Here is the XML that I have.
<ENV:Envelope xmlns:ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://example.com/soap/example">
<ENV:Body>
<ns1:GetCentresResponse>
<ExampleCentre>
<ns1:Cent>
<ID>200</ID>
<Name>example2</Name>
<Code>ex2</Code>
<Email>example2@example2.com</Email>
<Address1>example2, example2 </Address1>
<Address2>example2, example2 </Address2>
<City>example2</City>
<PostCode>111111</PostCode>
<Telephone>1111111111</Telephone>
<Location>11.11,-11.11</Location>
<URL>/example2/exam2/ex2</URL>
</ns1:Cent>
</ExampleCentre>
</ns1:GetCentresResponse>
</ENV:Body>
</ENV:Envelope>
I get this soap response from the server. I want to convert this to a array and store it in database. What should I do? I know the answer might be pretty straight forward, but hey, am a newbie 😀
Would really appreciate any help I get.
Thank you in anticipation.
Regards
The best solution would be to use PHP’s SoapClient class to do the call which will return you an object and then converting this object to an array, like so:
Which you can then store in the database.