ice78991
Programmer
- Nov 20, 2006
- 216
Trying to get a value from a .xml file using javascript but it is not returning any value. What should i be doing?
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = setDetails;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4) setDetails()
};
}
else
{
alert('Your browser can\'t handle this script');
return;
}
xmlDoc.load("info.xml");
}
function setDetails(){
alert(xmlDoc.childNodes[0].childNodes[0].nodeValue);
}
importXML();
Here is my xml file
<info>
<numberofimages>2</numberofimages>
</info>
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = setDetails;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {
if (xmlDoc.readyState == 4) setDetails()
};
}
else
{
alert('Your browser can\'t handle this script');
return;
}
xmlDoc.load("info.xml");
}
function setDetails(){
alert(xmlDoc.childNodes[0].childNodes[0].nodeValue);
}
importXML();
Here is my xml file
<info>
<numberofimages>2</numberofimages>
</info>