duanma8207 2017-02-17 00:06
浏览 32

PHP中的XML到数组的错误

Hi I trying to convert an XML file into a php array, all the nodes becomes well except this one.

<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>

The problem is that the attribute name is gone from the array, any idea why, thank you in advance.. here is my code and the array result.

$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"
    ]
  ]
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮