473,372 Members | 1,216 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,372 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 3067
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 ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.