Is there a simple way to handle nested namespaces with XML conversion in php? I am basically doing this:
$json = json_encode(simplexml_load_string($xml));
$array = json_decode($json, true);
But when simplexml_load_string returns empty when the XML has nested namespaces.
here's the xml: $xml=
'<ns1:XMLFault xmlns:ns1="cxf.apache.org/bindings/xformat">';
. '<ns1:faultstring xmlns:ns1="cxf.apache.org/bindings/xformat">Invalid instrument</ns1:faultstring>'
. '<ns1:detail xmlns:ns1="cxf.apache.org/bindings/xformat">';
. '<ns2:exceptionDetails xmlns:ns2="order.services.ordermgmt.dh.om.com/">';
. '<errorCode>instrument.invalid</errorCode>'
. '<errorMessage>Invalid instrument</errorMessage>'
. '</ns2:exceptionDetails>'
. '</ns1:detail>'
. '</ns1:XMLFault>';
I am looking to convert this into json or php associative array (I am a novice with XML namespaces).