PHP Classes

File: cvt_adrbook.php

Recommend this page to a friend!
  Classes of CPK Smithies   Palm Desktop   cvt_adrbook.php   Download  
File: cvt_adrbook.php
Role: Example script
Content type: text/plain
Description: Demonstrates conversion of address book file to XML
Class: Palm Desktop
Convert Palm Desktop files to other formats
Author: By
Last change:
Date: 11 years ago
Size: 767 bytes
 

Contents

Class file image Download
<?php
/**
 * Convert palm address book files to XML files
 * @author CPKS
 * @version 0.1
 * @package palmdata
 */

require 'adrbookfile.php';

/**
 * XML dump name.dat to name.xml
 * @param string $filename
 */
function cvt_adrbook($filename) {
 
$outfile = pathinfo($filename);
   
$outfile = $outfile['dirname'] . '/' . $outfile['filename'] . '.xml';
 
$pf = new palmdata\addressbookFile($filename);
   
$x = new \XMLWriter;
   
$x->openURI($outfile);
   
$x->setIndent(TRUE);
   
$pf->xdump($x, 'addressbook', 'contacts');
}

$progname = array_shift($argv);

while (
$fn = array_shift($argv)) {
  try {
       
cvt_adrbook($fn);
        echo
'converted ', basename($fn), PHP_EOL;
    }
    catch (\
Exception $e) {
      echo
"Exception caught whilst processing $fn:\n";
        echo
$e->getMessage();
    }
}