I have following XML response which I want to parse to an array:
$response = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="http://www.google.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="dominx.xsd">
<command>
<create>
<domain:create
xmlns:domain="http://www.google.com"
xsi:schemaLocation="domain-2.0.xsd">
<domain:name>xxxx</domain:name>
<domain:ns>xxxx</domain:ns>
<domain:ns>ns1.xxxx</domain:ns>
<domain:registrant>xxxx</domain:registrant>
<domain:contact type="tech">xxxxx</domain:contact>
<domain:authInfo>
<domain:pw>xxxx</domain:pw>
</domain:authInfo>
</domain:create>
</create>
</command>
</epp>';
function object2array($object) { return @json_decode(@json_encode($object),1); };
$xml = simplexml_load_string($response);
$xml_array=object2array($xml);
With above I'm getting empty array -> [create] => Array ( )
.
I would like to get full array in $xml_array
. Is it possible to get for this XML with simplexml or should I split this XML somehow ?