XML a la matriz usando simplexml_load_string
Necesito convertir XML a matriz, pero no está convirtiendo
aqui esta mi codigo
<?php
$response='<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Search xmlns="http:url">
<Request>
<aaa>string</aaa>
<bbb>string</bbb>
<ccc>srting</ccc>
<SourceName>string</SourceName>
</Request>
</Search>
</soap:Body>
</soap:Envelope>';
function xml2Array($xmlstring)
{
$xml = simplexml_load_string($xmlstring, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
return json_decode($json,TRUE);
}
$arr = xml2Array($response);
print_r($arr);
Pero si elimino
<soap:Body>
desde el XML funciona bien, ¿Cuál es el problema de cómo volver a resolverlo?