Hello!
I've written a code, that should be reading xml with js. But I have make an error. Can you help me?
LGHTML Code:<html> <head> <title>Test</title> <script type="text/javascript"><!-- var http = null; if (window.XMLHttpRequest) { http = new XMLHttpRequest(); } else if (window.ActiveXObject) { http = new ActiveXObject("Microsoft.XMLHTTP"); } window.onload = function() { if (http != null) { http.open("GET", "http://www.eucharistiefeier.de/lk/api/lkul00000000.xml", true); http.onreadystatechange = ausgeben; http.send(null); } } function ausgeben() { if (http.readyState == 4) { var bible = document.getElementById("bible"); var daten = http.responseXML; var ergebnisse = daten.getElementsByTagName("celebration"); for (var i = 0; i < ergebnisse.length; i++) { var name, url; var datum = ergebnisse[i]; for (var j = 0; j < datum.childNodes.length; j++) { with (datum.childNodes[j]) { if (nodeName == "l1") { name = firstChild.nodeValue; } else if (nodeName == "ev") { url = firstChild.nodeValue; } } } var p = document.createElement("p"); var r1 = document.createTextNode("Die heutige Tageslesung ist: " + name); p.appendChild(r1); bible.appendChild(p); } } } //--> </script> </head> <body> <ul id="bible"></ul> </body> </html>
Luensche
P. S.: Following error message came, when I let run "Firebug"
The error shold be in line 23, perhaps the problem is var http = null;Uncaught TypeError: Cannot call method 'getElementsByTagName' of null


Reply With Quote

Bookmarks