Hello,
I have a small problem with displaying a XML nodeValue. This is my code:
<html>
<head>
<script type="text/javascript">
var xmlDoc;
function loadXML()
{
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("http://webmail.tabor.nl/werenfridus/Rooster/Dagelijkse_rooster/lk_xml1.xml");
getmessage();
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation &&
document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument(""," ",null);
xmlDoc.load("http://webmail.tabor.nl/werenfridus/Rooster/Dagelijkse_rooster/lk_xml1.xml");
xmlDoc.onload=getmessage;
}
else
{
alert('Your browser cannot handle this script');
}
}
function getmessage()
{
var noitems
var noitems = xmlDoc.getElementsByTagName("item").length;
document.write("number of items: ",noitems);
document.write("<p>")
var lichtkrant = xmlDoc.getElementsByTagName("lichtkrant61");
var items = lichtkrant[0].getElementsByTagName("item");
var x=0
for (var x=0; x <= noitems; x=x+1)
{
var regel = items[x].getElementsByTagName("regel");
document.write("<p>");
document.write(regel[0].firstChild.nodeValue);
document.write("</p>");
}
}
</script>
</head>
<body>
Update me: <a href="#" onClick="loadXML()">Update HIM</a>
</body>
</html>
As you can see my XML file is located here: http://webmail.tabor.nl/werenfridus/Rooster/Dagelijkse_rooster/lk_xml1.xml
There are 36 items so noitems is 36, that's displayed right. However if I run this code there will only be 2 items displayed, the third nodevalue is empty, but I wonder will my for loop discontinue after it knows that my value is empty? If yes how can I fix this to display all node values?
Thanks for you time and help,
TK


LinkBack URL
About LinkBacks






Reply With Quote
