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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
    • ¥15 C# datagridview 单元格显示进度及值
    • ¥15 thinkphp6配合social login单点登录问题
    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配