SIMILE Widgets | Timeline with xml creation


I’ve recently been playing around with SIMILE Widgets | Timeline as it says on the site “With this widget, you can make beautiful interactive timelines”. The issue I had with this was that it ran on XML and the first time I looked at it I was not able to create an XML file so I put it aside. After playing around with XML over the last couple of years I stumbled on this again and decided to try and create a form that would add an entry to a database and in turn output an XML in the format that is required.

First you need to create a form to capture 3 key pieces of date (start date, finish date, tittle).

For the SMILE Timeline to work it needs to read an XML file with this sort of format.

<?xml version="1.0"?>
start="Monday ,1 November 2010 00:00:00 GMT"
latestStart="Tuesday ,16 November 2010 00:00:00 GMT"
earliestEnd="Thursday ,18 November 2010 23:00:00 GMT"
end="Tuesday ,23 November 2010 23:00:00 GMT"
title="Build Go Kart">

This is the code I use to create the XML file.

// Step 1
$sql = "select * from TABLE_NAME";
$result = mysql_query($sql) or die ( mysql_error() );

$output = "<?xml version=\"1.0\"?>\n";
$output .="<data\n";
$output .="wiki-url=\"\"\n";
$output .="wiki-section=\"\"\n";
$output .=">\n";

// Step 3
while ($line = mysql_fetch_assoc($result) ) {
 // Step 4
$output .= "<event \n";
 $output .= "start=\"" .date("l ,j F Y 00:00:00 \G\M\T", strtotime($line['Column_1'])). "\" \n";
 $output .= "start=\"" .date("l ,j F Y 00:00:00 \G\M\T", strtotime($line['Column_2'])). "\" \n";
$output .= "latestStart=\"" .date("l ,j F Y 00:00:00 \G\M\T", strtotime($line['Column_2'])). "\" \n";
$output .= "earliestEnd=\"" .date("l ,j F Y 23:00:00 \G\M\T", strtotime($line['Column_3'])). "\" \n";
 $output .= "end=\"" .date("l ,j F Y 23:00:00 \G\M\T", strtotime($line['Column_4'])). "\" \n";
 $output .= "end=\"" .date("l ,j F Y 23:00:00 \G\M\T", strtotime($line['Column_3'])). "\" \n";
$output .= "durationEvent=\"true\" \n";
$output .= "title=\"" . $line['Column_5'] . "\"> \n";
$output .= "\"" . $line['Column_6'] . "\"\n";
$output .= "</event>\n";

// Step 4
$output .= "</data>\n";

$myFile = "YourXMLFileName.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $output);

I’ve put together an example here.

One Response to “SIMILE Widgets | Timeline with xml creation”

  1. Bonny Longnecker Says:

    Hey, I haven’t checked in here for a while, but I will put you on my bloglist so I don’t forget to check back.

Leave a Reply

Powered by WordPress | Theme by Kordas.Industrial.Design Entries RSS Comments RSS