Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body style="background-color: green; font-family: Arial, Helvetica, sans-serif;">
- <p><button onclick="loadXMLLocal()">Load XML from local file</button><button onclick="loadXMLServer()">Load XML from steam server</button></p>
- <table id="table" border="0" style="color: white; text-shadow: 0 0 #000000;">
- </table>
- <script>
- function loadXMLLocal() {
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- myFunction(this);
- }
- };
- xmlhttp.open("GET", "current.xml" , true);
- xmlhttp.send();
- }
- function loadXMLServer() {
- var xmlhttp = new XMLHttpRequest();
- var URL = prompt("Please enter URL input", "http://steamcommunity.com/id/BatteryDie/stats/225420/achievements/");
- xmlhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- myFunction(this);
- }
- };
- xmlhttp.open("GET", URL +"?xml=1" , true);
- xmlhttp.send();
- }
- function myFunction(xml) {
- var x, i, xmlDoc, table;
- xmlDoc = xml.responseXML;
- table = "";
- x = xmlDoc.getElementsByTagName("achievement")
- for (i = 0; i < x.length; i++) {
- table += "<tr><td><b>" +
- x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue + "<br></b>" +
- x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue +
- "</td><td><img src=" +
- x[i].getElementsByTagName("iconClosed")[0].childNodes[0].nodeValue +
- "></td></tr>";
- }
- document.getElementById("table").innerHTML = table;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement