•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the RSS, Web Services and SOAP section within the Web Development category of DaniWeb, a massive community of 401,634 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,802 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 2270 | Replies: 0
![]() |
•
•
Join Date: Oct 2007
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
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:
<script language="javascript">
Load_XML("/SearchCenter/Documents/FOXindustries.xml");
decodeValue("Findustry_");
function Load_XML(XMLfilePath)
{ xmlDoc = ''
if (window.ActiveXObject)
{ //IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(XMLfilePath);
alert("loadIE");
return xmlDoc;
}
else if (document.implementation && document.implementation.createDocument)
{ //Firefox
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load(XMLfilePath);
alert("loadFF");
return xmlDoc;
}
else
{
return '';
}
}
function decodeValue(Prop)
{
var temp=''
for (k=1; k<=20; k++)
{
var temp=''
var separator = ''
if (document.getElementById(Prop_field.concat(k)) == null)
{ break;}
codeValue = document.getElementById(Prop_field.concat(k)).innerHTML;
multiCodeValue= codeValue.split(";");
for (j=0;j<multiCodeValue.length;j++)
{
SingleCodeValue = multiCodeValue[j].split(" ");
for (x=0;x<SingleCodeValue.length;x++)
{ ctr = 0; while (ctr < xmlDoc.documentElement.childNodes.length)
{if (xmlDoc.documentElement.childNodes[j].nodeType == 1)
{matchValue = xmlDoc.getElementsByTagName("urlValue")[ctr].childNodes[0].nodeValue;
}
if (SingleCodeValue[x] == matchValue)
{ if (temp!='' || separator != '' )
{
temp = temp + separator + xmlDoc.getElementsByTagName("textValue")[ctr].childNodes[0].nodeValue;
}
else
{
temp = xmlDoc.getElementsByTagName("textValue")[ctr].childNodes[0].nodeValue;
separator = ", "
}
}
ctr++;
}
}
}
if (temp != '')
{
temp = temp.replace(/;/g, " ; ")
document.getElementById(Prop_field.concat(k)).innerHTML = temp
}
}
}
</script>
It seems that the line in green is not being recognized by Firefox. Are there any codes that are compatible both in IE and Firefox???
Need help, please...
Thanks a lot in advance...
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:
<script language="javascript">
Load_XML("/SearchCenter/Documents/FOXindustries.xml");
decodeValue("Findustry_");
function Load_XML(XMLfilePath)
{ xmlDoc = ''
if (window.ActiveXObject)
{ //IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(XMLfilePath);
alert("loadIE");
return xmlDoc;
}
else if (document.implementation && document.implementation.createDocument)
{ //Firefox
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load(XMLfilePath);
alert("loadFF");
return xmlDoc;
}
else
{
return '';
}
}
function decodeValue(Prop)
{
var temp=''
for (k=1; k<=20; k++)
{
var temp=''
var separator = ''
if (document.getElementById(Prop_field.concat(k)) == null)
{ break;}
codeValue = document.getElementById(Prop_field.concat(k)).innerHTML;
multiCodeValue= codeValue.split(";");
for (j=0;j<multiCodeValue.length;j++)
{
SingleCodeValue = multiCodeValue[j].split(" ");
for (x=0;x<SingleCodeValue.length;x++)
{ ctr = 0; while (ctr < xmlDoc.documentElement.childNodes.length)
{if (xmlDoc.documentElement.childNodes[j].nodeType == 1)
{matchValue = xmlDoc.getElementsByTagName("urlValue")[ctr].childNodes[0].nodeValue;
}
if (SingleCodeValue[x] == matchValue)
{ if (temp!='' || separator != '' )
{
temp = temp + separator + xmlDoc.getElementsByTagName("textValue")[ctr].childNodes[0].nodeValue;
}
else
{
temp = xmlDoc.getElementsByTagName("textValue")[ctr].childNodes[0].nodeValue;
separator = ", "
}
}
ctr++;
}
}
}
if (temp != '')
{
temp = temp.replace(/;/g, " ; ")
document.getElementById(Prop_field.concat(k)).innerHTML = temp
}
}
}
</script>
It seems that the line in green is not being recognized by Firefox. Are there any codes that are compatible both in IE and Firefox???
Need help, please...
Thanks a lot in advance...
![]() |
•
•
•
•
•
•
•
•
DaniWeb RSS, Web Services and SOAP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
api asp beta blogger blogging bon browser browsers browsing code development dom echo email encryption europe feed firefox gdata google home html internet internet explorer internet explorer 7 javascript linux microsoft mozilla news open-source patch pedophiles programming reader rss security software standards super survey testing video w3c weather web webmail work xml xoap
- Previous Thread: View an xml file in ie
- Next Thread: Adding Attributes to all XML Nodes


Linear Mode