I have the fokllowing xml string that i'd like to convert to a json string.
Here is the xml in a variable:
$output = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://api-v1.gen.mm.vodafone.com/mminterface/request"><soapenv:Header/><soapenv:Body><req:ResponseMsg><![CDATA[<?xml version="1.0" encoding="UTF-8"?><response xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/response"><ResponseCode>100000014</ResponseCode><ResponseDesc>Missing mandatory parameter:OriginatorConversationId</ResponseDesc><ConversationID></ConversationID><OriginatorConversationID></OriginatorConversationID><ServiceStatus>0</ServiceStatus></response>]]></req:ResponseMsg></soapenv:Body></soapenv:Envelope>';
Then I'm using this regex to convert it but it returns blank.
$pattern = "(<Response(.+)>[\s\S]*?<\/Response>)";preg_match_all($pattern, $output, $matches);$xml = simplexml_load_string($matches[0][0]);echo json_encode($xml);
What am i missing?