Advice on displaying new xml data every minute

Associate
Joined
18 Oct 2002
Posts
1,641
Location
The Moon
I have a little project that I need some help with. I basically have an HTML page with a table in that displays data from an xml file. Now this displays fine but I need the page to refresh every 1 minute, and display new data from a new xml file. I can do the auto refresh bit, but obviously the file name of the xml file will change.

The xml filename will take the format of 15102006_1326.xml then the next will be 15102006_1327 e.t.c (so a timestamp in effect)

So what I need to do is have the html file change its source to look at the next xml file every 1 minute

Any ideas or tips?

TIA :)
 
Well, it needs to be dynamic, so you need to use a scripting language of some kind.

You could either do it client-side using javascript, or server-side with a language like PHP, Perl or a .NET. What do you have available to you? All will provide you with some method to generate the relevant timestamp and incrementing key.
 
How are you transforming/displaying the XML? CSS, XSLT? Where/how is the source XML file requested?

To generate the timestamp, you can use the Date object in javascript e.g
Code:
<script type="text/javascript">
var date    = new Date()
var day     = date.getDate();
var month   = date.getMonth();
var year    = date.getFullYear();
var hours   = date.getHours();
var minutes = date.getMinutes();
var output = '' + day + month + year + '_' + hours + minutes + '.xml';

alert(output);
</script>
But you'd need to account for zero-padding, and the fact that month goes from 0-11 etc.
 
Right here is the struture of the html document

Code:
<html>
<body>

<xml id="15102006_1315" src="15102006_1315.xml"></xml>
<meta http-equiv="refresh" content="10;URL=.......ekoner.html">
<table border="1" datasrc="#ekoner">

<thead>
<tr><th>Data1</th><th>Data2</th><th>Data3</th><th>Data4</th></tr>
</thead>

<tbody>
<tr>
<td><span datafld="Data1"></span></td>
<td><span datafld="Data2"></span></td>
<td><span datafld="Data3"></span></td>
<td><span datafld="Data4"></span></td>
</tr>
</tbody>

</table>

</body>
</html>

And the xml looks like this

Code:
<?xml version="1.0"?>
<dataset>
 <row>
<Data1>1315</Data1>   <Data2>2006-10-11 16:00:00</Data2>   <Data3>Soccer - Fixtures</Data3>   <Data4>Belarus v Slovenia</Data4></row>
</dataset>
 <row>

So that xml document has the name of 15102006_1315.xml and that is referenced in the html document. After 1 minute, a new one is uploaded as 15102006_1516.xml and that now needs to be read in the html document.

Hope I have made sense :)
 
Back
Top Bottom