473,385 Members | 1,907 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,385 software developers and data experts.

Display XML nodes whose parent node has a certain attribute (or attribute value)

57
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=loadXMLDoc("sampleFileZ.xml");
x=xmlDoc.getElementsByTagName("sampleNode");
for (i=0;i<x.length;i++)
{
if (x[i].parentNode.hasAttribute("sampleAtt"))
{
document.write(x[i].childNodes[0].nodeValue)
document.write("<br />")
}
}
</script>

---------------------------------------

This one works in IE, but not FF:

<script language="JavaScript" type="text/javascript">
xmlDoc=loadXMLDoc("sampleFile.xml");
xmlDoc.setProperty("SelectionLanguage", "XPath");
x=xmlDoc.selectNodes("//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!
Apr 26 '07 #1
2 1852
drhowarddrfine
7,435 Expert 4TB
Probably not the problem but this is not valid:
<script language="JavaScript" type="text/javascript">

Change it to:
<script type="text/javascript">
Apr 26 '07 #2
npm
57
Thanks! I changed it.

Does anyone have a suggestion on how to work this out?
Apr 27 '07 #3

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

Similar topics

3
by: Michael Reiche | last post by:
Question on XSL expression Got this XML: <Body> <Page> <Line no="9" detail="true"> <onefield>onefieldstext</onefield> <twofield>twofieldstext</twofield> </Line>
4
by: bearclaws | last post by:
I want to select certain nodes from an XML file whose parent nodes contain a particular attribute id. For instance, here's a sample XML file: <AAA> <BBB id="111">text <CCC>text</CCC> </BBB>...
0
by: ajchan16 | last post by:
Hi, I have an issue that I just cannot figure out. I currently have an XML file that I would like to populate into a datagrid on my windows application. Now I know how to use the DataView to...
14
by: neerajb | last post by:
Hi, I am having an XML document(input.xml) which is showing the menu heirarchy used in my application.My requirement is to add "submenu" tag to those menuitems who are having the child menuitems...
3
by: Irocivan | last post by:
Hello, I download a nice collapse menu for free distribution from the internet. It works very well except that none of the parents nodes are clickable (i.e. when clicking on the parent node, the...
4
by: jmDesktop | last post by:
I have searched everywhere and tried several things. I have a treeview with and want to be able to only select a parent node. For example: root //don't want to drag this -parent1 //yes, drag...
5
by: AdrianGawrys | last post by:
Hi Guys, I have an xml similar to this one: <?xml version="1.0" encoding="UTF-8"?> <SystemUpdate ForceUpdate="false" > <A ForceUpdate="false"> <Book name="Black" /> <Book...
1
by: SWETA123 | last post by:
I will very helpful to you if you can help me out in my below problem. I am not getting idea what should be the right approach for this. Here is my problem. I have below (sample)xml. <Rules>...
2
by: tookerello | last post by:
hi, im trying to display the attribute name of the parent node once the input matches a town name: my xml is: <phonebook> <area code="022"> <town>mallow</town> </area> <area...
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...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.