Coding Fun Html XML FILE RUN WITH HTML AND FIREFOXMOZILLA

XML FILE RUN WITH HTML AND FIREFOXMOZILLA




Tags: , , , , , , , , , , , , , , , , , , , ,

1 thought on “XML FILE RUN WITH HTML AND FIREFOXMOZILLA”

  1. SAVE MONEY says:

    —————————————————————————————————————————————-
    XML FILE RUN WITH HTML AND FIREFOX MOZILLA
    —————————————————————————————————————————————-
    http://fbgadgets.blogspot.co.uk/2017/04/xml-file-run-with-html-and-firefox.html
    —————————————————————————————————————————————-
    <html>
    <head>
    <style>
    table,th,td {
    border : 1px solid black;
    border-collapse: collapse;
    }
    th,td {
    padding: 5px;
    }
    </style>
    </head>
    <body contenteditable="false">
    <button type="button" onclick="loadXMLDoc()">Get my CD collection</button>
    <br><br>
    <table id="demo">
    <script>
    function loadXMLDoc() {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
    myFunction(this);
    }
    };
    xmlhttp.open("GET", "https://www.w3schools.com/xml/cd_catalog.xml&quot;, true);
    xmlhttp.send();
    }
    function myFunction(xml) {
    var i;
    var xmlDoc = xml.responseXML;
    var table="<tr><th>Artist</th><th>Title</th></tr>";
    var x = xmlDoc.getElementsByTagName("CD");
    for (i = 0; i <x.length; i++) {
    table += "<tr><td>" +
    x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue +
    "</td><td>" +
    x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue +
    "</td></tr>";
    }
    document.getElementById("demo").innerHTML = table;
    }
    </script>
    </body>
    </html>

Leave a Reply

Your email address will not be published. Required fields are marked *