所以我有这个XML: -
<ApiResponse Status="OK">
<Errors/>
<Warnings/>
<RequestedCommand>namecheap.domains.getlist</RequestedCommand>
<CommandResponse Type="namecheap.domains.getList"></CommandResponse>
<Server>PHX01SBAPI02</Server>
<GMTTimeDifference>--7:00</GMTTimeDifference>
<ExecutionTime>0.07</ExecutionTime>
</ApiResponse>
如何访问&#34; 状态&#34;的价值?在 ApiResponse ?
我试过了: -
foreach($xml->ApiResponse->attributes() as $a => $b) {
echo $a,'="',$b,"\"\n";
}
但它引发了这个错误: -
main(): Node no longer exists
答案 0 :(得分:-1)
尝试simplexml_load_string ..
$xmlArray = simplexml_load_string($xml);
$json = json_encode($xmlArray);
$xmlFormated = json_decode($json,TRUE);
print_r($xmlFormated);