Tryit Editor v1.4

<html> <head> <script type="text/javascript"> var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load("cd_catalog.xml"); var x=xmlDoc.getElementsByTagName("CD"); i=0; function next() { if (i<x.length-1) { i++; display(); } } function previous() { if (i>0) { i--; display(); } } function display() { artist=(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue); title=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); year=(x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue); document.getElementById("show").innerHTML="Artist: " + artist + "<br />Title: " + title + "<br />Year: "+ year; } </script> </head> <body onload="display()"> <div id='show'> </div> <br /> <input type="button" onclick="previous()" value="previous" /> <input type="button" onclick="next()" value="next" /> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself