Quantcast
Viewing latest article 1
Browse Latest Browse All 2

Answer by iainn for Convert xml string to json in php

You'll find it a lot easier if you also process the outer SOAP document with SimpleXML, rather than trying to force it into a regex. It might look a bit complicated because of the namespaces, but it's quite straightforward using the SimpleXML::children() method:

$soap = simplexml_load_string($output);$response = $soap    ->children('http://schemas.xmlsoap.org/soap/envelope/')    ->Body    ->children('http://api-v1.gen.mm.vodafone.com/mminterface/request')    ->ResponseMsg;$xml = simplexml_load_string(trim($response));// ...

See https://3v4l.org/iQIAT for a full demo

(As an aside, using json_encode directly with a SimpleXML object can have a couple of strange side-effects, but should work ok with this document. You might find it more reliable to just extract the values you want using SimpleXML's own API, e.g. $xml->ResponseCode)


Viewing latest article 1
Browse Latest Browse All 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>