You must Sign In to post a response.
  • Category: JavaScript

    I want to retrieve a message in xml and show in marquee scrolling

    i have emp1.xml like
    <?xml version="1.0" encoding="UTF-8"?><Company>
    <Staff>
    <month>12</month>
    <date>31</date>
    <message>"If you are ready to believe, you are easy to deceive" </message>
    </Staff>

    <Staff>
    <month>12</month>
    <date>30</date>
    <message>"Before you can score you must first have a goal." </message>
    </Staff>

    <Staff>
    <month>12</month>
    <date>29</date>
    <message>"Before you can score you must first have a goal." </message>
    </Staff>



    <Staff>
    <month>12</month>
    <date>28</date>
    <message>"If you are ready to believe, you are easy to deceive" </message>
    </Staff>

    <Staff>
    <month>12</month>
    <date>27</date>
    <message>"All the flowers of tomorrow are in the seeds of yesterday" </message>
    </Staff>
    below is the javascript ihavewritten toretrieve month,date and message from xml and show in marqueescrolling
    <td><marquee style="font-family:arial; color: #FFFFFF" bgcolor="#990000" scrollamount="20" width='250%'>

    <script type="text/javascript">
    document.write(dayname[day] + ", ");
    document.write(monthname[month] + " ");
    document.write(date + ", ");
    document.write(year + " ");
    // January
    i = 0;
    for (i=0;i<x.length;i++)
    {
    //alert(i);
    //alert(month);
    var x=null;
    var y=null;
    var z=null;
    var Z=null;
    var d=new Date();
    var monthNumber = d.getMonth()+1;
    var nodes = xmlDoc.getElementsByTagName("Staff");
    for(j=0;j<nodes.length;j++)
    {

    x=xmlDoc.getElementsByTagName("month")[j]
    y=x.childNodes[0];
    z=xmlDoc.getElementsByTagName("date")[j]
    Z=z.childNodes[0];

    if(monthNumber==y.nodeValue)
    {
    if(date==Z.nodeValue)
    {
    var message = xmlDoc.getElementsByTagName("message")[j] ;
    var Message = message.childNodes[0];
    document.write("" +Message.nodeValue);
    }
    }
    }
    }

    //if ((month == monthname[month]) && (date == date))
    //document.write(" Happy Birthday To " +x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);

    </script>

    </marquee> </td>


    i am not getting message in scroll bar so please help me correctly
  • #757476
    First check if you have successfully read XML file, try to put some ALERT's in your javascript code and check if it able to read you messages that you want to show in MARQUEE tag
    With the help of JQuery you can be able to put marquee in your code, I got some nice links for it
    http://www.javascriptkit.com/javatutors/marquee4.shtml
    http://jsfiddle.net/FWWEn/
    http://jsfiddle.net/zrW5q/1442/

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


  • Sign In to post your comments