1
我需要一些问题的帮助:我正在使用PHP脚本将XML转换为CSV,但我有这个问题,他们是属性中的属性。另一个PHP - XML到CSV转换问题与fputcsv
这是XML文件的结构:
<Products>
<Product>
<Name>
SomeProductName
</Name>
<Colour>
Black
</Colour>
<Features>
<Feature_0>
this is feature 0
</Feature_0>
<Feature_1>
this is feature 1
</Feature_1>
<Feature_2>
this is feature 1
</Feature_2>
</Features>
<Product>
</Product>
,这是我的脚本:
{$filexml='product.xml';
if (file_exists($filexml)) {
$xml = simplexml_load_file($filexml);
$f = fopen('product.csv', 'w');
foreach($xml->Products->Product as $product) {
$values = array(
"Name" => $product->Name,
"Colour" => $product->Colour,
"Features" => $product->Features);
fputcsv($f, $values,',','"');
}
fclose($f);
}
这个剧本我只得到Feature_0,我需要让我的CSV所有这些功能文件。 任何帮助将不胜感激。
在此先感谢!
谢谢,回答我的问题。我想,我会保留它作为一个很好的解决方案xml现在只是。因为我对平坦化/合并这两个.csv不太了解。再次感谢你 –
欢迎:) – hek2mgl