Greetings,
I'm new to this forum, and am excited at the possiblity of reaching out to all of you for assistance. I of course, will assist others as well when i get the opportunity.
PROBLEM SYNOPISIS: My XML javascript code does not work properly in FireFox. I've been up and down this problem ... i've narrowed it down to the fact that when i getElementsByTagName("channel") the subsequent array has no properties.
Here is a basic version of what i'm working with:
That's the basic javascript. It works fine in IE (of course) but fails in FireFox with the error console indicating "x[0] has no properties" - i guess i just don't understand how that is possible.HTML Code:<script language="javascript" type="text/javascript"> var browser var xmlDoc function browserDetect() { // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("firefox.xml"); browser="ie"; testPhrase2(); } else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); xmlDoc.load("firefox.xml"); browser="ff"; var isLoaded = xmlDoc.load("firefox.xml"); if (isLoaded==true){testPhrase2();} } else { alert('Your browser cannot handle this script'); } } function testPhrase2(){ if (browser=="ie"){ var x=xmlDoc.getElementsByTagName("channel"); var channelName; channelName=x[0].childNodes[0].childNodes[0].nodeValue; document.getElementById(browser).innerHTML="This is an IE confirmation: "+ channelName; } else if (browser=="ff") { var x=xmlDoc.getElementsByTagName("channel"); var channelName; channelName=x[0].childNodes[0].childNodes[0].nodeValue; document.getElementById(browser).innerHTML="This is an FF confirmation: "+ channelName; } } </script>
Below is the basix XML document used for this example:
I've tried so many things ... i thought it was a whitespace issue (it's not), i thought it was a load delay issue (it is not) and now i'm simply out of ideas.HTML Code:<?xml version="1.0" encoding="iso-8859-1"?> <channels> <channel> <name>XXX</name> <status>YYY</status> </channel> <channel> <name>ZZZ</name> <status>YYY</status> </channel> </channels>
I humbly submit to anyone's help who is willing to assist.
Thank you in advance,
satelliteCoder



Reply With Quote

Bookmarks