Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body style="background-color: green; font-family: Arial, Helvetica, sans-serif;">
  4.  
  5. <p><button onclick="loadXMLLocal()">Load XML from local file</button><button onclick="loadXMLServer()">Load XML from steam server</button></p>
  6.  
  7. <table id="table" border="0" style="color: white; text-shadow: 0 0 #000000;">
  8. </table>
  9.  
  10. <script>
  11. function loadXMLLocal() {
  12. var xmlhttp = new XMLHttpRequest();
  13. xmlhttp.onreadystatechange = function() {
  14. if (this.readyState == 4 && this.status == 200) {
  15. myFunction(this);
  16. }
  17. };
  18. xmlhttp.open("GET", "current.xml" , true);
  19. xmlhttp.send();
  20. }
  21. function loadXMLServer() {
  22. var xmlhttp = new XMLHttpRequest();
  23. var URL = prompt("Please enter URL input", "http://steamcommunity.com/id/BatteryDie/stats/225420/achievements/");
  24. xmlhttp.onreadystatechange = function() {
  25. if (this.readyState == 4 && this.status == 200) {
  26. myFunction(this);
  27. }
  28. };
  29. xmlhttp.open("GET", URL +"?xml=1" , true);
  30. xmlhttp.send();
  31. }
  32.  
  33. function myFunction(xml) {
  34. var x, i, xmlDoc, table;
  35. xmlDoc = xml.responseXML;
  36. table = "";
  37. x = xmlDoc.getElementsByTagName("achievement")
  38. for (i = 0; i < x.length; i++) {
  39. table += "<tr><td><b>" +
  40. x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue + "<br></b>" +
  41. x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue +
  42. "</td><td><img src=" +
  43. x[i].getElementsByTagName("iconClosed")[0].childNodes[0].nodeValue +
  44. "></td></tr>";
  45. }
  46. document.getElementById("table").innerHTML = table;
  47. }
  48. </script>
  49.  
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement