I'm trying to display XML nodes whose parent node has a certain attribute (or attribute value). I have one code that works in Firefox, but not IE and another code that works in IE, but not Firefox.
This one works in FF, but not IE:
<script type="text/javascript">
xmlDoc=loadXMLD oc("sampleFileZ .xml");
x=xmlDoc.getEle mentsByTagName( "sampleNode ");
for (i=0;i<x.length ;i++)
{
if (x[i].parentNode.has Attribute("samp leAtt"))
{
document.write( x[i].childNodes[0].nodeValue)
document.write( "<br />")
}
}
</script>
---------------------------------------
This one works in IE, but not FF:
<script language="JavaS cript" type="text/javascript">
xmlDoc=loadXMLD oc("sampleFile. xml");
xmlDoc.setPrope rty("SelectionL anguage", "XPath");
x=xmlDoc.select Nodes("//node1[@att='value']/node2");
for (i=0;i<x.length ;i++)
{
document.write( x[i].childNodes[0].nodeValue)
document.write( "<br />")
}
</script>
Is there one javascript (maybe one like the first one that uses an if statement) that will work in both browsers?
Thanks so much!
This one works in FF, but not IE:
<script type="text/javascript">
xmlDoc=loadXMLD oc("sampleFileZ .xml");
x=xmlDoc.getEle mentsByTagName( "sampleNode ");
for (i=0;i<x.length ;i++)
{
if (x[i].parentNode.has Attribute("samp leAtt"))
{
document.write( x[i].childNodes[0].nodeValue)
document.write( "<br />")
}
}
</script>
---------------------------------------
This one works in IE, but not FF:
<script language="JavaS cript" type="text/javascript">
xmlDoc=loadXMLD oc("sampleFile. xml");
xmlDoc.setPrope rty("SelectionL anguage", "XPath");
x=xmlDoc.select Nodes("//node1[@att='value']/node2");
for (i=0;i<x.length ;i++)
{
document.write( x[i].childNodes[0].nodeValue)
document.write( "<br />")
}
</script>
Is there one javascript (maybe one like the first one that uses an if statement) that will work in both browsers?
Thanks so much!
Comment