No. I still get the same error; "Object doesn't support this action".
Main Topics
Browse All TopicsAt present I am working on a web application which processes an XML file retreived from the server using the XMLHTTP object. I'm looping through the childNodes in the XML file and testing the nodeName property of each so I can determine which functions I need to pass each node to.
For example, I pass the XML object to a function called process:
function process(xml) {
for (var i in xml.childNodes) {
if (xml.childNodes[i].nodeNam
alert('you got a sponge');
}
}
}
This works correctly in Firefox, but I have a problem in IE. I have an error which says "Object doesn't support this action", referring to the line where I start my For In loop.
If I do this instead (a normal For loop):
function process(xml) {
for (var i =0; i < xml.childNodes.length; ++i) {
if (xml.childNodes[i].nodeNam
alert('you got a sponge');
}
}
}
It does work correctly in IE. I don't what to have to do this since it is more code and means modifying all the For In loops I am using throughout the application.
Anyone know why IE is freaking out over the For In loop?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I do not understand what you expect from Experts???
You do not want to change the loop to the obvious solution and expect some shorter workaround?
Did you test what properties you get in the for loop with the "in"?
So as you see you get also the childNodes length as a property name beside the indexes, so does this statement make no sense:
if (xml.childNodes["length"].
The workaround would be to test first wheter a node with the i index exist, but that is obviously longer the the stright way of looping trough the index given by length and not looping trough all properties of childNodes:
if (xml.childNodes["length"]&
Do you see the difference betwean looping trough numerc indexes givven by length and all properties givven by "in" loop?
> I do not understand what you expect from Experts???
Expertise obviously, not antagonism.
>You do not want to change the loop to the obvious solution and expect some shorter workaround?
No I don't want to change the loop if I can avoid it, because I have used the For In loop extensively in the XML processing code. If there is no other solution I would quite happily use a normal For loop, but I thought that at least I could find out for certain by asking here.
> Did you test what properties you get in the for loop with the "in"?
Yes, I get the same error "Object doesn't support this action".
> So as you see you get also the childNodes length as a property name beside the indexes, so does this
> statement make no sense:
> if (xml.childNodes["length"].
I understand that. That is not my problem here. Simply, I am unable to loop through the properties of the XML object in IE using the For In loop.
even if I do something like
for (i in xml) {
alert(i)
}
I would expect the code to alert the name of each property and method. It doesn't even do that. I get the "..doesn't support action.." error.
IE does not directly support XML, that is why yu have to use activex for xml related operations. More advanced browsers like Mozilla/FF can use the whole document as a nodeList because build everything as a dom object. IE can't do that very well because it has to screw up the DOM to support proprietary legacy objects like document.all
Try bringing in the data with XMLDOM and then see if the nodeList you get in the documentElement.childNodes
No guarantees of course. With IE what will or will not work within standards is always a crap shoot.
Cd&
Business Accounts
Answer for Membership
by: knightEknightPosted on 2005-03-30 at 20:26:10ID: 13668652
does this work?
for (i in xml.childNodes) {