您好我尝试将XML文件转换为php数组,除此之外,所有节点都会很好。
<category name="Wheels and Tires">
<specification name="Front Tire Type">P245/40R18</specification>
<specification name="Front Wheel Diameter">18.0 x 8.0</specification>
<specification name="Rear Tire Type">P245/40R18</specification>
<specification name="Rear Wheel Diameter">18.0 x 8.0</specification>
</category>
问题是属性名称已从数组中消失,任何想法为什么,谢谢你提前..这里是我的代码和数组结果。
$xml = curl_exec($ch); // $result now contains the response JSON or XML.
$xml_string = simplexml_load_string($xml);
$json = json_encode($xml_string);
$xml_parse = json_decode($json, TRUE);
return($xml_parse);
array:2 [▼
"@attributes" => array:1 [▶]
"specification" => array:4 [▼
0 => "P245/40R18"
1 => "18.0 x 8.0"
2 => "P245/40R18"
3 => "18.0 x 8.0"
]
]