<?xml version="1.0" encoding="utf-8" ?><ELEM_LIST><ELEM PLAYER_NAME="TRANCESTATION.RU VK.COM/TRSTATION" SCH_ID="0" SCH_NAME="Default" STATUS="playing"><START_TIME>02:58:07</START_TIME><START_DATE>2017-11-04</START_DATE><BLK_TYPE>Ð</BLK_TYPE><TYPE>Ð</TYPE><NAME>Don't Forget Me</NAME><ARTIST>Abide</ARTIST><AUTHOR></AUTHOR><ALBUM></ALBUM><DBID></DBID><FILE_NAME>D:\site_radio\music\trance\TR120816_006.mp3</FILE_NAME><DURATION>00:03:45</DURATION></ELEM><ELEM PLAYER_NAME="TRANCESTATION.RU VK.COM/TRSTATION +79789267837" SCH_ID="0" SCH_NAME="Default" STATUS="preloaded"><BLK_TYPE>Ð</BLK_TYPE><TYPE>Ð</TYPE><NAME>Safe Inside You</NAME><ARTIST>Rising Star ft. Betsie Larkin</ARTIST><AUTHOR></AUTHOR><ALBUM></ALBUM><DBID></DBID><FILE_NAME>D:\site_radio\music\trance\TR230816_014.mp3</FILE_NAME><DURATION>00:04:39</DURATION></ELEM></ELEM_LIST>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" > <xsl:output omit-xml-declaration="yes" method="text" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="no" encoding="UTF-8" /><xsl:strip-space elements="*"/> <xsl:template match = "/icestats" > <xsl:for-each select="source"> <xsl:if test="artist"><xsl:value-of select="artist" /> - </xsl:if><xsl:value-of select="title" /> </xsl:for-each> </xsl:template> </xsl:stylesheet>
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>XML LOAD TEST</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { function seconds2time(seconds) { var hours = Math.floor(seconds / 3600); var minutes = Math.floor((seconds - (hours * 3600)) / 60); var seconds = seconds - (hours * 3600) - (minutes * 60); var time = ""; if (hours != 0) { time = hours + ":"; } if (minutes != 0 || time !== "") { minutes = (minutes < 10 && time !== "") ? "0" + minutes : String(minutes); time += minutes + ":"; } if (time === "") { if (seconds === 0) { time = ""; } else { time = "0:" + seconds; } } else { time += (seconds < 10) ? "0" + seconds : String(seconds); } return time; } function time2seconds(str) { var p = str.split(':'), s = 0, m = 1; while (p.length > 0) { s += m * parseInt(p.pop(), 10); m *= 60; } return s; } function show_metadata() { var timestamp = new Date().getTime(); $.ajax({ url: 'load_xml.php?' + timestamp, dataType: 'xml', success: function(data) { var xml_node = $('ELEM_LIST', data); var playing = xml_node.find('ELEM[STATUS="playing"]'); var artist = playing.find('ARTIST').text(); var title = playing.find('NAME').text(); var start_date = playing.find('START_DATE').text(); var start_time = playing.find('START_TIME').text(); var duration = playing.find('DURATION').text(); $.get('server_time.php?' + timestamp, function(server_time) { $('#contdown').html(time2seconds(duration) + Date.parse(start_date + ' ' + start_time) / 1000 - server_time + time_correction); }); $('#meta').html(artist + ' - ' + title); }, error: function(data) { console.log('Error loading XML data'); } }); } var time_correction = 10; setInterval(function() { var timer = Math.max(0, parseInt($('#contdown').html())); if (timer > 0) { timer--; } else { show_metadata(); } $('#contdown').html(timer); $('#time').html(seconds2time(timer)); }, 1000); }) </script> </head> <body> <div id="meta"></div> <div id="time"></div> <div id="contdown" style="display:none;">0</div> </body> </html>
<?php echo file_get_contents("(path to xml file)?" . time()); ?>
<?php echo time(); ?>