Jump to content

Parsing Xml


jjbigfish

Recommended Posts

Simplest way I can think of is

<?php
$fh = fopen('mycsv.csv', 'w');

$xml = simplexml_load_file('example.xml');
foreach ($xml->xpath('//App') as $app) {
   $data = array (
           (string)$app['id'],
           (string)$app['action'],
           (string)$app['ref'],
           (string)$app->BaseVehicle['id'],
           (string)$app->EngineBase['id'],
           (string)$app->Qty,
           (string)$app->PartType['id'],
           (string)$app->MfrLabel,
           (string)$app->Part
           );
   fputcsv($fh, $data);
}
fclose($fh);
?>

Link to comment
https://forums.phpfreaks.com/topic/271719-parsing-xml/#findComment-1398159
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.