473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Script for accessing throught childNodes of XML file is not working in Firefox

Hi everyone,

I have this code in javascript where the XML file is loaded and displayed to an html using XSLT. It works fine in IE but not in Firefox. My problem is in the looping to the childNodes. It seems that Firefox does not recognize this line of code >> xmlDoc.getElementsByTagName("urlValue")[ctr].childNodes[0].nodeValue

I'm not sure if this is the line that is not working, or the lines before it. I'm looping to the childNodes to compare to my generated code value and retrieve its equivalent text value so that the one displayed to the HTML is the text value by using the XSLT.

Here is the javascript code:
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.  
  3. Load_XML("/SearchCenter/Documents/FOXindustries.xml");
  4. decodeValue("Findustry_");
  5.  
  6. function Load_XML(XMLfilePath) 
  7. { xmlDoc = ''
  8. if (window.ActiveXObject)
  9. { //IE 
  10. xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  11. xmlDoc.async=false;
  12. xmlDoc.load(XMLfilePath); 
  13. alert("loadIE");
  14. return xmlDoc; 
  15. else if (document.implementation && document.implementation.createDocument)
  16. { //Firefox
  17. xmlDoc=document.implementation.createDocument("","",null);
  18. xmlDoc.load(XMLfilePath);
  19. alert("loadFF");
  20. return xmlDoc;
  21. }
  22. else
  23. {
  24. return '';
  25. }
  26. }
  27.  
  28. function decodeValue(Prop)
  29. var temp=''
  30. for (k=1; k<=20; k++)
  31. var temp=''
  32. var separator = ''
  33. if (document.getElementById(Prop_field.concat(k)) == null)
  34. { break;}
  35. codeValue = document.getElementById(Prop_field.concat(k)).innerHTML;
  36. multiCodeValue= codeValue.split(";");
  37. for (j=0;j<multiCodeValue.length;j++) 
  38. SingleCodeValue = multiCodeValue[j].split(" "); 
  39. for (x=0;x<SingleCodeValue.length;x++) 
  40. { ctr = 0; while (ctr < xmlDoc.documentElement.childNodes.length)
  41. {matchValue = xmlDoc.getElementsByTagName("urlValue")[ctr].childNodes[0].nodeValue;
  42. }
  43. if (SingleCodeValue[x] == matchValue)
  44. { if (temp!='' || separator != '' )
  45. temp = temp + separator + xmlDoc.getElementsByTagName("textValue")[ctr].childNodes[0].nodeValue;
  46. }
  47. else
  48. temp = xmlDoc.getElementsByTagName("textValue")[ctr].childNodes[0].nodeValue;
  49. separator = ", "
  50. }
  51. ctr++;
  52. }
  53. }
  54. }
  55. if (temp != '')
  56. {
  57. temp = temp.replace(/;/g, " ; ")
  58. document.getElementById(Prop_field.concat(k)).innerHTML = temp 
  59. }
  60. }
  61. }
  62. </script>
  63.  
Can anyone help me???

This code works fine in IE but not in Firefox...

What code will i use in order for this to work both in IE and Firefox.???
Jan 15 '08 #1
2 3069
jkmyoung
2,057 Expert 2GB
I'm not entirely sure, but I think you have your braces misplaced.
I don't think you should have your closing brace after
matchValue = xmlDoc.getElementsByTagName("urlValue")[ctr].childNodes[0].nodeValue;

Was this added accidentally?
Jan 15 '08 #2
I'm not entirely sure, but I think you have your braces misplaced.
I don't think you should have your closing brace after
matchValue = xmlDoc.getElementsByTagName("urlValue")[ctr].childNodes[0].nodeValue;

Was this added accidentally?

Yes, this was accidentally added. It's not supposed to be there. I added several lines of codes before I posted it here. I forgot to delete this one... Thanks... Also, I wasn't able to edit Prop_field... its supposed to be Prop based on the argument passed.

Also, I debugged this code using the firebug and I noticed that the documentElement at the while loop contains NULL. Did I load the XML Document correctly?
Jan 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dan | last post by:
does anyone know why this script doesnt work propertly the images on the right side can not be displayed here is the script i use function initSettings () { for ( var i = 1; i <= 50; i++){...
5
by: zaw | last post by:
Hi I am working on implementing this script to shopping cart. Basically, it copies fill the shipping address from billing automatically. I believe one or more syntax is not netscape compatible....
4
by: Alvaro G Vicario | last post by:
I have a list built on HTML and CSS: <ul> <li>Foo</li> <li>Bar <ul> <li>Gee</li> </ul> </li> </ul>
6
by: Ron Brennan | last post by:
Good evening. <span id=fileList> <input type=hidden name=file id=file_0 value=Name/> </span> .... document.getElementById(fileList).childNodes The childNodes is giving me two children: 1)...
23
by: Loony | last post by:
I have got a code like this in HTML section in ASP file which includes javascript file! The script works under MS IE but doesn't with Firefox! Can anybody tell me what is wrong? <HTML>...
7
by: cjl | last post by:
Hey all: I've searched the newsgroup, and googled, but I'm stuck. I want to be able to 'dynamically' add a .js file to a web page after the page has loaded, based on user interaction. For...
4
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is...
7
by: mattrapoport | last post by:
Hello - I am kinda new to the HTML DOM so I apologize in advance for my ignorance. I have a table made from divs. I am trying to write a script that appends a new row to the table (by cloning...
1
by: ehud37new | last post by:
this script work fine in IE but not in FireFox where is the problem? here is the script /*------------------------------------------------------------------ File: menu.js ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.