Forum Moderators: open
I have been struggling with this for a while now.
What I am trying to do is get info from an XML page using JavaScript.
I have found loads of code, and have tried almost everything to get it to work in both IE and FF...
But with no success...
I have code that works in FF but not in IE
My JS Code:
//******************************************************
var xmlDoc;
var txt_head = "";
var txt_content = "";
function loadXML(str_xmlelement, int_functype)
{
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("helpContent.xml");
if (int_functype == "1") {
getXMLhead(str_xmlelement);
}
else if (int_functype == "2") {
getXMLbody(str_xmlelement);
}
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation &&
document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("helpContent.xml");
if (int_functype == "1") {
xmlDoc.onload=getXMLhead(str_xmlelement);
}
else if (int_functype == "2") {
getXMLbody(str_xmlelement);
}
}
else
{
alert('Your browser cannot handle this script');
}
}
function getXMLhead(str_xmlelement) {
alert("no ");
var x=xmlDoc.documentElement.childNodes;
//document.getElementByTagname("person").attributes.getNamedItem("name").value
for (var I=0;i<x.length;i++)
{
if (x[I].tagName == str_xmlelement)
{
//Process only element nodes
txt_head = x[I].childNodes[1].firstChild.nodeValue;
}
}
}
function getXMLbody(str_xmlelement) {
alert("way ");
var x=xmlDoc.documentElement.childNodes;
for (var I=0;i<x.length;i++)
{
if (x[I].tagName == str_xmlelement)
{
txt_content = x[I].childNodes[3].firstChild.nodeValue;
}
}
}
//******************************************************
What I am trying to do:
I have a function(1) that calls a function(2) that get the data from an XML file..
Makes sense?
Help?