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="xxxxxx"
xmlns:xsi="xxxxxx"
xsi:schemaLocation="xxxxxx">
<command>
<create>
<domain:create
xmlns:domain="xxxxxx"
xsi:schemaLocation="xxxxxx">
<domain:name>xxxxxx</domain:name>
<domain:ns>ns1.xxxxxx</domain:ns>
<domain:ns>ns1.xxxxxx</domain:ns>
<domain:registrant>xxxxxx</domain:registrant>
<domain:contact type="tech">xxxxxx</domain:contact>
<domain:authInfo>
<domain:pw>xxxxxx</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 ?
No comments:
Post a Comment