Created
December 4, 2015 13:39
-
-
Save vojtasvoboda/ab7da1eed9ed79774427 to your computer and use it in GitHub Desktop.
xml2csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once('vendor/autoload.php'); | |
// debugger | |
use Tracy\Debugger; | |
Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/log'); | |
// load file | |
$content = file_get_contents(__DIR__ . '/data/data.xml'); | |
$xml = new SimpleXMLElement($content); | |
// iterate items | |
echo '<html><head><title>csv2xml</title><meta charset="utf-8" /></head><body><table><br />'; | |
foreach($xml->channel->item as $item) { | |
if( empty($item->ggtin)) { | |
echo '<tr>'; | |
echo '<td>' . $item->gid . "</td><td>" . $item->title . "</td><td>" . $item->link . '</td>'; | |
echo '</tr><br />'; | |
} | |
} | |
echo '</table></body></html>'; | |
exit('ok'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment