【发布时间】:2018-01-03 15:47:53
【问题描述】:
我需要将 xml 转换为数组:
XML
?xml version="1.0" standalone="yes"?>
<DocumentElement>
<article>
<a>TEST></a>
<b>TEST2</b>
<c>TEST3</c>
</article>
<article>
<a>TEST4></a>
<b>TEST5</b>
<c>TEST6</c>
</article>
</DocumentElement>
我需要一个这样的数组:
$testArray = array(
array('a' => TEST, 'b' => 'TEST2', 'c' => TEST3),
array('a' => TEST4, 'b' => 'TEST5', 'c' => TEST6)
);
我的第一次尝试是:
$file = "product.xml";
$productArray = @simplexml_load_file($file) or
die ("ERROR loading file");
但是用那个方法我得到一个数组。
关于如何做到这一点的任何建议?
【问题讨论】: