Start a new topic

Create a template file

Hello everyone,


I was tired of creating template files for imports so I made a little PHP script to do it automatically!

You will need PHP to run this (http://windows.php.net/download/)

It runs from the command line and takes the exported XML profile as a parameter

Enjoy!  and let me know if you have any problems




if (!isset($argv[1])) {

exit("ERROR: Must supply XML profile export file name");

}

$filename = $argv[1];

$xml = simplexml_load_file($filename);

$csv_file = fopen(explode('.', $filename)[0] . '.csv','w');

foreach ($xml->Rows->anyType as $row) {

if($row->Type == "Normal") {

$header[] = $row->FieldName;

}

}

fputcsv($csv_file, $header);

unset($header);

foreach ($xml->Rows->anyType as $row) {

if($row->Type == "Normal") {

$header[] = "(" . $row->RecordType['translation'] . (isset($row->ValueType['translation']) ? ": " . $row->ValueType['translation'] : "") . ")";

}

}

fputcsv($csv_file, $header);

fclose($csv_file);


?>

Login or Signup to post a comment