<?php
/**
* Convert palm datebook files to XML files
* @author CPKS
* @version 1.0
* @package palmdata
*/
require 'datebookfile.php';
/**
* Dump file.dat to file.xml
* @param string $filename
*/
function cvt_datebook($filename) {
$outfile = pathinfo($filename);
$outfile = $outfile['dirname'] . '/' . $outfile['filename'] . '.xml';
$pf = new palmdata\datebookFile($filename);
$x = new \XMLWriter;
$x->openURI($outfile);
$x->setIndent(TRUE);
$pf->xdump($x);
}
$progname = array_shift($argv);
palmdata\datebookFile::register_event_class('palmdata\xcalitem');
while ($fn = array_shift($argv)) {
try {
cvt_datebook($fn);
echo 'converted ', basename($fn), PHP_EOL;
}
catch (\Exception $e) {
echo "Exception caught whilst processing $fn:\n";
echo $e->getMessage();
}
}
|