How to display text on a website from htm or xml file that is updated every time












0















I'm working on the radio site and for streaming, the Jazler RadioStar 2 program is used which allows constant updating of files that transmit the information which song is currently streaming..



check image



I am specifically interested in how to transfer the title of the song and the name of the author to my homepage..



customexportfile.htm code



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Trenutno Slusate!</title>
</head>

<body>

<p>TNowOnAir: <strong>Cher | Believe</strong>

</body>

</html>


or via xml file, NowOnAir.xml



<Schedule System="Jazler">
<Event status="happening" startTime="09:15:30" eventType="song">
<Announcement Display=""/>
<Song title="Believe">
<Artist name="Cher"> </Artist>
<Jazler ID="6379"/>
<PlayLister ID=""/>
<Media runTime="03:34"/>
<Expire Time="09:19:03"/>
</Song>
</Event>
</Schedule>


These files are automatically updated when the song on the stream changes.










share|improve this question























  • Use ajax to get information from the server without reloading the page

    – FZs
    Dec 31 '18 at 8:41






  • 1





    Can you explain me better, I'm noob in scripting..

    – Mark
    Dec 31 '18 at 8:42











  • AJAX is stand for Asynchronous Javascript And Xml. You can set timeouts in JavaScript to request data (XML, JSON, text or anything) from server

    – FZs
    Dec 31 '18 at 8:49











  • I'm sorry, but can you do the code, I'm not a programmer and I do not understand the best of these things..

    – Mark
    Dec 31 '18 at 8:57
















0















I'm working on the radio site and for streaming, the Jazler RadioStar 2 program is used which allows constant updating of files that transmit the information which song is currently streaming..



check image



I am specifically interested in how to transfer the title of the song and the name of the author to my homepage..



customexportfile.htm code



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Trenutno Slusate!</title>
</head>

<body>

<p>TNowOnAir: <strong>Cher | Believe</strong>

</body>

</html>


or via xml file, NowOnAir.xml



<Schedule System="Jazler">
<Event status="happening" startTime="09:15:30" eventType="song">
<Announcement Display=""/>
<Song title="Believe">
<Artist name="Cher"> </Artist>
<Jazler ID="6379"/>
<PlayLister ID=""/>
<Media runTime="03:34"/>
<Expire Time="09:19:03"/>
</Song>
</Event>
</Schedule>


These files are automatically updated when the song on the stream changes.










share|improve this question























  • Use ajax to get information from the server without reloading the page

    – FZs
    Dec 31 '18 at 8:41






  • 1





    Can you explain me better, I'm noob in scripting..

    – Mark
    Dec 31 '18 at 8:42











  • AJAX is stand for Asynchronous Javascript And Xml. You can set timeouts in JavaScript to request data (XML, JSON, text or anything) from server

    – FZs
    Dec 31 '18 at 8:49











  • I'm sorry, but can you do the code, I'm not a programmer and I do not understand the best of these things..

    – Mark
    Dec 31 '18 at 8:57














0












0








0








I'm working on the radio site and for streaming, the Jazler RadioStar 2 program is used which allows constant updating of files that transmit the information which song is currently streaming..



check image



I am specifically interested in how to transfer the title of the song and the name of the author to my homepage..



customexportfile.htm code



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Trenutno Slusate!</title>
</head>

<body>

<p>TNowOnAir: <strong>Cher | Believe</strong>

</body>

</html>


or via xml file, NowOnAir.xml



<Schedule System="Jazler">
<Event status="happening" startTime="09:15:30" eventType="song">
<Announcement Display=""/>
<Song title="Believe">
<Artist name="Cher"> </Artist>
<Jazler ID="6379"/>
<PlayLister ID=""/>
<Media runTime="03:34"/>
<Expire Time="09:19:03"/>
</Song>
</Event>
</Schedule>


These files are automatically updated when the song on the stream changes.










share|improve this question














I'm working on the radio site and for streaming, the Jazler RadioStar 2 program is used which allows constant updating of files that transmit the information which song is currently streaming..



check image



I am specifically interested in how to transfer the title of the song and the name of the author to my homepage..



customexportfile.htm code



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Trenutno Slusate!</title>
</head>

<body>

<p>TNowOnAir: <strong>Cher | Believe</strong>

</body>

</html>


or via xml file, NowOnAir.xml



<Schedule System="Jazler">
<Event status="happening" startTime="09:15:30" eventType="song">
<Announcement Display=""/>
<Song title="Believe">
<Artist name="Cher"> </Artist>
<Jazler ID="6379"/>
<PlayLister ID=""/>
<Media runTime="03:34"/>
<Expire Time="09:19:03"/>
</Song>
</Event>
</Schedule>


These files are automatically updated when the song on the stream changes.







javascript html xml stream id






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 31 '18 at 8:37









MarkMark

35




35













  • Use ajax to get information from the server without reloading the page

    – FZs
    Dec 31 '18 at 8:41






  • 1





    Can you explain me better, I'm noob in scripting..

    – Mark
    Dec 31 '18 at 8:42











  • AJAX is stand for Asynchronous Javascript And Xml. You can set timeouts in JavaScript to request data (XML, JSON, text or anything) from server

    – FZs
    Dec 31 '18 at 8:49











  • I'm sorry, but can you do the code, I'm not a programmer and I do not understand the best of these things..

    – Mark
    Dec 31 '18 at 8:57



















  • Use ajax to get information from the server without reloading the page

    – FZs
    Dec 31 '18 at 8:41






  • 1





    Can you explain me better, I'm noob in scripting..

    – Mark
    Dec 31 '18 at 8:42











  • AJAX is stand for Asynchronous Javascript And Xml. You can set timeouts in JavaScript to request data (XML, JSON, text or anything) from server

    – FZs
    Dec 31 '18 at 8:49











  • I'm sorry, but can you do the code, I'm not a programmer and I do not understand the best of these things..

    – Mark
    Dec 31 '18 at 8:57

















Use ajax to get information from the server without reloading the page

– FZs
Dec 31 '18 at 8:41





Use ajax to get information from the server without reloading the page

– FZs
Dec 31 '18 at 8:41




1




1





Can you explain me better, I'm noob in scripting..

– Mark
Dec 31 '18 at 8:42





Can you explain me better, I'm noob in scripting..

– Mark
Dec 31 '18 at 8:42













AJAX is stand for Asynchronous Javascript And Xml. You can set timeouts in JavaScript to request data (XML, JSON, text or anything) from server

– FZs
Dec 31 '18 at 8:49





AJAX is stand for Asynchronous Javascript And Xml. You can set timeouts in JavaScript to request data (XML, JSON, text or anything) from server

– FZs
Dec 31 '18 at 8:49













I'm sorry, but can you do the code, I'm not a programmer and I do not understand the best of these things..

– Mark
Dec 31 '18 at 8:57





I'm sorry, but can you do the code, I'm not a programmer and I do not understand the best of these things..

– Mark
Dec 31 '18 at 8:57












2 Answers
2






active

oldest

votes


















0















  1. Make a text file to the same directory as NowOnAir.xml!

  2. Name it like filename.html

  3. Type the following inside:





<!DOCTYPE html>

<html>

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
</head>

<body onload="refresh()">

<p>Now playing: <span id="art"></span>|<span id="title"></span>

<script>
var interval,time
function refresh(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("art").innerHTML = this.responseXML.getElementByTagName("ARTIST")[0].getAttribute("name");
document.getElementById("title").innerHTML = this.responseXML.getElementByTagName("SONG")[0].getAttribute("title");
time=this.responseXML.getElementByTagName("EXPIRE")[0].getAttribute("Time").split(":")
interval=setInterval(checkTime,1000)
}
};
xhttp.open("GET", "NowOnAir.xml", true);
xhttp.send();
}
}
function checkTime(){
var date=new Date()
if(date.getSeconds()==time[2]&&date.getMinutes()==time[1]&&date.getHours()==time[0]){
clearInterval(interval)
refresh()
}
}

</script>
</body>
</html>



  1. Then try it (you will find it like this: http://serveraddress/path/filename.html)


I hope that this will help you!






share|improve this answer
























  • I tried this and got two error in the console : i.postimg.cc/K85yw7Hc/Capture.png

    – Mark
    Dec 31 '18 at 12:17











  • Otherwise the site on which I work is on the wordpress platform, if it is something that is important..

    – Mark
    Dec 31 '18 at 12:23



















0














Hesitantly, you can try out this code...



N.B.




  1. There are a great many reasons why this might not work (from the outset, or later).

  2. You should certainly test this out in an environment where it will not upset anyone if it doesn't work.

  3. The solution below involves checking for a new song and title every 5 seconds using the Javascript setInterval method. That could well be a wholly inappropriate solution because it will run indefinitely every 5 seconds. Without more information, it's impossible to answer this for you really.

  4. This code is untested.


Anyway, here's a punt at solving this problem:



HTML (homepage):



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Trenutno Slusate!</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>

<body>

<p>NowOnAir:
<strong>
<span id="artistName">Cher</span> |
<span id="songTitle">Believe</span>
</strong>
</p>
<script>
function getNowPlaying() {
const src = "NowOnAir.xml";
$.ajax({
type: 'GET',
url: src,
dataType: xml,
success: function(xml) {

//parse XML
const xmlDoc = $.parseXML( xml );
const $doc = $( xmlDoc );
const $artist = $doc.find( "Artist" ).attr("name").text();
const $song = $doc.find( "Song" ).attr("title").text();

//update homepage
$("#artistName").text($artist);
$("#songTitle").text($song);

},
error: function(e) {
console.log(e);
}
})
}

setInterval( function() {
getNowPlaying();
}, 5000);
</script>
</body>

</html>


If it doesn't work, feel free to comment and I'll try to help.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53985282%2fhow-to-display-text-on-a-website-from-htm-or-xml-file-that-is-updated-every-time%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0















    1. Make a text file to the same directory as NowOnAir.xml!

    2. Name it like filename.html

    3. Type the following inside:





    <!DOCTYPE html>

    <html>

    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    </head>

    <body onload="refresh()">

    <p>Now playing: <span id="art"></span>|<span id="title"></span>

    <script>
    var interval,time
    function refresh(){
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
    document.getElementById("art").innerHTML = this.responseXML.getElementByTagName("ARTIST")[0].getAttribute("name");
    document.getElementById("title").innerHTML = this.responseXML.getElementByTagName("SONG")[0].getAttribute("title");
    time=this.responseXML.getElementByTagName("EXPIRE")[0].getAttribute("Time").split(":")
    interval=setInterval(checkTime,1000)
    }
    };
    xhttp.open("GET", "NowOnAir.xml", true);
    xhttp.send();
    }
    }
    function checkTime(){
    var date=new Date()
    if(date.getSeconds()==time[2]&&date.getMinutes()==time[1]&&date.getHours()==time[0]){
    clearInterval(interval)
    refresh()
    }
    }

    </script>
    </body>
    </html>



    1. Then try it (you will find it like this: http://serveraddress/path/filename.html)


    I hope that this will help you!






    share|improve this answer
























    • I tried this and got two error in the console : i.postimg.cc/K85yw7Hc/Capture.png

      – Mark
      Dec 31 '18 at 12:17











    • Otherwise the site on which I work is on the wordpress platform, if it is something that is important..

      – Mark
      Dec 31 '18 at 12:23
















    0















    1. Make a text file to the same directory as NowOnAir.xml!

    2. Name it like filename.html

    3. Type the following inside:





    <!DOCTYPE html>

    <html>

    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    </head>

    <body onload="refresh()">

    <p>Now playing: <span id="art"></span>|<span id="title"></span>

    <script>
    var interval,time
    function refresh(){
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
    document.getElementById("art").innerHTML = this.responseXML.getElementByTagName("ARTIST")[0].getAttribute("name");
    document.getElementById("title").innerHTML = this.responseXML.getElementByTagName("SONG")[0].getAttribute("title");
    time=this.responseXML.getElementByTagName("EXPIRE")[0].getAttribute("Time").split(":")
    interval=setInterval(checkTime,1000)
    }
    };
    xhttp.open("GET", "NowOnAir.xml", true);
    xhttp.send();
    }
    }
    function checkTime(){
    var date=new Date()
    if(date.getSeconds()==time[2]&&date.getMinutes()==time[1]&&date.getHours()==time[0]){
    clearInterval(interval)
    refresh()
    }
    }

    </script>
    </body>
    </html>



    1. Then try it (you will find it like this: http://serveraddress/path/filename.html)


    I hope that this will help you!






    share|improve this answer
























    • I tried this and got two error in the console : i.postimg.cc/K85yw7Hc/Capture.png

      – Mark
      Dec 31 '18 at 12:17











    • Otherwise the site on which I work is on the wordpress platform, if it is something that is important..

      – Mark
      Dec 31 '18 at 12:23














    0












    0








    0








    1. Make a text file to the same directory as NowOnAir.xml!

    2. Name it like filename.html

    3. Type the following inside:





    <!DOCTYPE html>

    <html>

    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    </head>

    <body onload="refresh()">

    <p>Now playing: <span id="art"></span>|<span id="title"></span>

    <script>
    var interval,time
    function refresh(){
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
    document.getElementById("art").innerHTML = this.responseXML.getElementByTagName("ARTIST")[0].getAttribute("name");
    document.getElementById("title").innerHTML = this.responseXML.getElementByTagName("SONG")[0].getAttribute("title");
    time=this.responseXML.getElementByTagName("EXPIRE")[0].getAttribute("Time").split(":")
    interval=setInterval(checkTime,1000)
    }
    };
    xhttp.open("GET", "NowOnAir.xml", true);
    xhttp.send();
    }
    }
    function checkTime(){
    var date=new Date()
    if(date.getSeconds()==time[2]&&date.getMinutes()==time[1]&&date.getHours()==time[0]){
    clearInterval(interval)
    refresh()
    }
    }

    </script>
    </body>
    </html>



    1. Then try it (you will find it like this: http://serveraddress/path/filename.html)


    I hope that this will help you!






    share|improve this answer














    1. Make a text file to the same directory as NowOnAir.xml!

    2. Name it like filename.html

    3. Type the following inside:





    <!DOCTYPE html>

    <html>

    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    </head>

    <body onload="refresh()">

    <p>Now playing: <span id="art"></span>|<span id="title"></span>

    <script>
    var interval,time
    function refresh(){
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
    document.getElementById("art").innerHTML = this.responseXML.getElementByTagName("ARTIST")[0].getAttribute("name");
    document.getElementById("title").innerHTML = this.responseXML.getElementByTagName("SONG")[0].getAttribute("title");
    time=this.responseXML.getElementByTagName("EXPIRE")[0].getAttribute("Time").split(":")
    interval=setInterval(checkTime,1000)
    }
    };
    xhttp.open("GET", "NowOnAir.xml", true);
    xhttp.send();
    }
    }
    function checkTime(){
    var date=new Date()
    if(date.getSeconds()==time[2]&&date.getMinutes()==time[1]&&date.getHours()==time[0]){
    clearInterval(interval)
    refresh()
    }
    }

    </script>
    </body>
    </html>



    1. Then try it (you will find it like this: http://serveraddress/path/filename.html)


    I hope that this will help you!







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 31 '18 at 10:27









    FZsFZs

    1,3742824




    1,3742824













    • I tried this and got two error in the console : i.postimg.cc/K85yw7Hc/Capture.png

      – Mark
      Dec 31 '18 at 12:17











    • Otherwise the site on which I work is on the wordpress platform, if it is something that is important..

      – Mark
      Dec 31 '18 at 12:23



















    • I tried this and got two error in the console : i.postimg.cc/K85yw7Hc/Capture.png

      – Mark
      Dec 31 '18 at 12:17











    • Otherwise the site on which I work is on the wordpress platform, if it is something that is important..

      – Mark
      Dec 31 '18 at 12:23

















    I tried this and got two error in the console : i.postimg.cc/K85yw7Hc/Capture.png

    – Mark
    Dec 31 '18 at 12:17





    I tried this and got two error in the console : i.postimg.cc/K85yw7Hc/Capture.png

    – Mark
    Dec 31 '18 at 12:17













    Otherwise the site on which I work is on the wordpress platform, if it is something that is important..

    – Mark
    Dec 31 '18 at 12:23





    Otherwise the site on which I work is on the wordpress platform, if it is something that is important..

    – Mark
    Dec 31 '18 at 12:23













    0














    Hesitantly, you can try out this code...



    N.B.




    1. There are a great many reasons why this might not work (from the outset, or later).

    2. You should certainly test this out in an environment where it will not upset anyone if it doesn't work.

    3. The solution below involves checking for a new song and title every 5 seconds using the Javascript setInterval method. That could well be a wholly inappropriate solution because it will run indefinitely every 5 seconds. Without more information, it's impossible to answer this for you really.

    4. This code is untested.


    Anyway, here's a punt at solving this problem:



    HTML (homepage):



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Trenutno Slusate!</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    </head>

    <body>

    <p>NowOnAir:
    <strong>
    <span id="artistName">Cher</span> |
    <span id="songTitle">Believe</span>
    </strong>
    </p>
    <script>
    function getNowPlaying() {
    const src = "NowOnAir.xml";
    $.ajax({
    type: 'GET',
    url: src,
    dataType: xml,
    success: function(xml) {

    //parse XML
    const xmlDoc = $.parseXML( xml );
    const $doc = $( xmlDoc );
    const $artist = $doc.find( "Artist" ).attr("name").text();
    const $song = $doc.find( "Song" ).attr("title").text();

    //update homepage
    $("#artistName").text($artist);
    $("#songTitle").text($song);

    },
    error: function(e) {
    console.log(e);
    }
    })
    }

    setInterval( function() {
    getNowPlaying();
    }, 5000);
    </script>
    </body>

    </html>


    If it doesn't work, feel free to comment and I'll try to help.






    share|improve this answer




























      0














      Hesitantly, you can try out this code...



      N.B.




      1. There are a great many reasons why this might not work (from the outset, or later).

      2. You should certainly test this out in an environment where it will not upset anyone if it doesn't work.

      3. The solution below involves checking for a new song and title every 5 seconds using the Javascript setInterval method. That could well be a wholly inappropriate solution because it will run indefinitely every 5 seconds. Without more information, it's impossible to answer this for you really.

      4. This code is untested.


      Anyway, here's a punt at solving this problem:



      HTML (homepage):



      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">

      <head>
      <meta content="en-us" http-equiv="Content-Language" />
      <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
      <title>Trenutno Slusate!</title>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      </head>

      <body>

      <p>NowOnAir:
      <strong>
      <span id="artistName">Cher</span> |
      <span id="songTitle">Believe</span>
      </strong>
      </p>
      <script>
      function getNowPlaying() {
      const src = "NowOnAir.xml";
      $.ajax({
      type: 'GET',
      url: src,
      dataType: xml,
      success: function(xml) {

      //parse XML
      const xmlDoc = $.parseXML( xml );
      const $doc = $( xmlDoc );
      const $artist = $doc.find( "Artist" ).attr("name").text();
      const $song = $doc.find( "Song" ).attr("title").text();

      //update homepage
      $("#artistName").text($artist);
      $("#songTitle").text($song);

      },
      error: function(e) {
      console.log(e);
      }
      })
      }

      setInterval( function() {
      getNowPlaying();
      }, 5000);
      </script>
      </body>

      </html>


      If it doesn't work, feel free to comment and I'll try to help.






      share|improve this answer


























        0












        0








        0







        Hesitantly, you can try out this code...



        N.B.




        1. There are a great many reasons why this might not work (from the outset, or later).

        2. You should certainly test this out in an environment where it will not upset anyone if it doesn't work.

        3. The solution below involves checking for a new song and title every 5 seconds using the Javascript setInterval method. That could well be a wholly inappropriate solution because it will run indefinitely every 5 seconds. Without more information, it's impossible to answer this for you really.

        4. This code is untested.


        Anyway, here's a punt at solving this problem:



        HTML (homepage):



        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">

        <head>
        <meta content="en-us" http-equiv="Content-Language" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <title>Trenutno Slusate!</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        </head>

        <body>

        <p>NowOnAir:
        <strong>
        <span id="artistName">Cher</span> |
        <span id="songTitle">Believe</span>
        </strong>
        </p>
        <script>
        function getNowPlaying() {
        const src = "NowOnAir.xml";
        $.ajax({
        type: 'GET',
        url: src,
        dataType: xml,
        success: function(xml) {

        //parse XML
        const xmlDoc = $.parseXML( xml );
        const $doc = $( xmlDoc );
        const $artist = $doc.find( "Artist" ).attr("name").text();
        const $song = $doc.find( "Song" ).attr("title").text();

        //update homepage
        $("#artistName").text($artist);
        $("#songTitle").text($song);

        },
        error: function(e) {
        console.log(e);
        }
        })
        }

        setInterval( function() {
        getNowPlaying();
        }, 5000);
        </script>
        </body>

        </html>


        If it doesn't work, feel free to comment and I'll try to help.






        share|improve this answer













        Hesitantly, you can try out this code...



        N.B.




        1. There are a great many reasons why this might not work (from the outset, or later).

        2. You should certainly test this out in an environment where it will not upset anyone if it doesn't work.

        3. The solution below involves checking for a new song and title every 5 seconds using the Javascript setInterval method. That could well be a wholly inappropriate solution because it will run indefinitely every 5 seconds. Without more information, it's impossible to answer this for you really.

        4. This code is untested.


        Anyway, here's a punt at solving this problem:



        HTML (homepage):



        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">

        <head>
        <meta content="en-us" http-equiv="Content-Language" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <title>Trenutno Slusate!</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        </head>

        <body>

        <p>NowOnAir:
        <strong>
        <span id="artistName">Cher</span> |
        <span id="songTitle">Believe</span>
        </strong>
        </p>
        <script>
        function getNowPlaying() {
        const src = "NowOnAir.xml";
        $.ajax({
        type: 'GET',
        url: src,
        dataType: xml,
        success: function(xml) {

        //parse XML
        const xmlDoc = $.parseXML( xml );
        const $doc = $( xmlDoc );
        const $artist = $doc.find( "Artist" ).attr("name").text();
        const $song = $doc.find( "Song" ).attr("title").text();

        //update homepage
        $("#artistName").text($artist);
        $("#songTitle").text($song);

        },
        error: function(e) {
        console.log(e);
        }
        })
        }

        setInterval( function() {
        getNowPlaying();
        }, 5000);
        </script>
        </body>

        </html>


        If it doesn't work, feel free to comment and I'll try to help.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 31 '18 at 10:47









        jonhendrixjonhendrix

        958




        958






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53985282%2fhow-to-display-text-on-a-website-from-htm-or-xml-file-that-is-updated-every-time%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas