Hi everyone. I’m using this code, wich I got from the web (I can’t find the source yet, but I’m still looking for it to post it):
[CODE]
<script type=”text/javascript”>
var xmlDoc;
function parseXML()
{
try //Internet Explorer
{
xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);
}
catch(e)
{
try //Firefox, Mozilla, Opera, etc.
{
xmlDoc=document.implementation.createDocument(“”,””,null);
}
catch(e)
{
alert(e.message);
return;
}
}
xmlDoc.onload = init;
xmlDoc.async = false;
xmlDoc.load(“code.xml”);
}
function init()
{
alert(xmlDoc.getElementsByTagName(“keywordlist”).length);
}
My xml file is quite simple:
<?xml version=”1.0″ encoding=”utf-8″?>
<keywordlist>
<keyword>dim</keyword>
<keyword>false</keyword>
<keyword>true</keyword>
</keywordlist>
Alert window shows me 0 as length of elements with tagname keywordlist. If I try to access any other properties of methods of XML DOM object, it sometimes return me null things and other times just doesn’t show logical results i.e. if I call xmlDoc.documentElement.childNodes[0].nodeValue, it returns me null. What’s wrong with this code?. Thanks for advance. Regards.