How to parse data from a xml into a table and make it update changes live



I have stumbled upon a bit of a issue and I'm hoping that I can get some help/pointer here how to overcome it.

I have an external xml file that I need to parse and display in the table. I did this. The issue is that the file is updating every second, so I would like the data in the cells to update "live" as well, according to the changes in xml file.

The problem is that I don't know what should I use to do it. Can anyone please point me into right direction.



<?php
require('simple_html_dom.php');
$html = file_get_html('http://ift.tt/1B2aqUK');
foreach($html->find('response') as $row) {
$frontdoorlock = $row->find('led1',0)->plaintext;
$reardoorlock = $row->find('led2',0)->plaintext;
$fronthandle = $row->find('btn0',0)->plaintext;
$frontdoor = $row->find('btn1',0)->plaintext;
$rearhandle = $row->find('btn2',0)->plaintext;
$reardoor = $row->find('btn3',0)->plaintext;
$temperature = $row->find('temp0',0)->plaintext;
$humidity = $row->find('humid0',0)->plaintext;
$currentdate = $row->find('temp2',0)->plaintext;
$lastpowered = $row->find('temp3',0)->plaintext;
}
?>
<div>
<table>
<tr>
<td>
Cabinet Name
</td>
<td >
Front Door Lock
</td>
<td>
Front Handle
</td>
<td>
Front Door
</td>
<td>
Rear Door Lock
</td>
<td>
Rear Handle
</td>
<td>
Rear Door
</td>
<td>
Temperature
</td>
<td>
Humidity
</td>
<td>
Current Date
</td>
<td>
System Last Powered
</td>
</tr>
<tr>
<td>
Cab1
</td>
<td >
<?php if($frontdoorlock == "0") echo "CLOSED";
else echo "OPEN";
?>
</td>
<td>
<?php if($fronthandle == "0") echo "CLOSED";
else echo "OPEN";
?>
</td>
<td>
<?php if($frontdoor == "0") echo "OPEN";
else echo "CLOSED";
?>
</td>
<td>
<?php if($reardoorlock == "0") echo "CLOSED";
else echo "OPEN";
?>
</td>
<td>
<?php if($rearhandle == "0") echo "CLOSED";
else echo "OPEN";
?>
</td>
<td>
<?php if($reardoor == "0") echo "OPEN";
else echo "CLOSED";
?>
</td>
<td>
<?php echo $temperature; ?>
</td>
<td>
<?php echo $humidity; ?>
</td>
<td>
<?php echo $currentdate ?>
</td>
<td>
<?php echo $lastpowered ?>
</td>
</tr>

No comments:

Post a Comment