jjbigfish Posted December 7, 2012 Share Posted December 7, 2012 I would like to parse this example.xml file using PHP, and output it to a CSV file. Any help would be appreciated. example.xml Link to comment https://forums.phpfreaks.com/topic/271719-parsing-xml/ Share on other sites More sharing options...
Maq Posted December 7, 2012 Share Posted December 7, 2012 http://bit.ly/VskTyd Link to comment https://forums.phpfreaks.com/topic/271719-parsing-xml/#findComment-1398121 Share on other sites More sharing options...
Barand Posted December 7, 2012 Share Posted December 7, 2012 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.