Item List for XML Node in IE

P

Prashant Mahajan

Hi All,

I am facing a problem regarding accessing the item list of an XML node
in IE.
While using the following code:

for(test in XMLNode) {}

I received this XML Node from AJAX's responseXML. This fetches item
list in Mozilla and Opera, however it creates errors in IE.

Any help or support will be highly appreciated.


Prashant Mahajan
Interra Information Technologies (India) Pvt. Ltd.
E-21, NSEZ, NOIDA, U.P. 201305
Web-Site : http://geocities.com/mrprashantmahajan
 
M

Martin Honnen

Prashant said:
I am facing a problem regarding accessing the item list of an XML node
in IE.
While using the following code:

for(test in XMLNode) {}

I received this XML Node from AJAX's responseXML.

You can access XMLNode.childNodes, the child nodes that nodes have, as a
node list. You can then iterate over that list with a normal for loop
for (var i = 0, c = XMLNode.childNodes, l = c.length; i < l; i++) {
var child = c;
}

On the other hand your example does not really make sense to me if
XMLNode is really a single XML DOM node as that loop would then iterate
over the property names of that node.
 
P

Prashant Mahajan

Martin said:
Prashant said:
I am facing a problem regarding accessing the item list of an XML node
in IE.
While using the following code:

for(test in XMLNode) {}

I received this XML Node from AJAX's responseXML.

You can access XMLNode.childNodes, the child nodes that nodes have, as a
node list. You can then iterate over that list with a normal for loop
for (var i = 0, c = XMLNode.childNodes, l = c.length; i < l; i++) {
var child = c;
}

On the other hand your example does not really make sense to me if
XMLNode is really a single XML DOM node as that loop would then iterate
over the property names of that node.


I am sorry If I stated the question in an incorrect way. I don't want
the children of the XML node. I want to iterate through the item list
of the object. Items like:
1. XMLNode.nodeName
2. XMLNode.getAttribute
3. XMLNode.childNodes
4. XMLNode.nodeValue
5. XMLNode.nodeType
6. XMLNode.parentNode
7. XMLNode.firstChild
and so on...
 
M

Martin Honnen

Prashant said:
I am sorry If I stated the question in an incorrect way. I don't want
the children of the XML node. I want to iterate through the item list
of the object. Items like:
1. XMLNode.nodeName
2. XMLNode.getAttribute
3. XMLNode.childNodes
4. XMLNode.nodeValue
5. XMLNode.nodeType
6. XMLNode.parentNode
7. XMLNode.firstChild

These are the properties/members of the object. But XML nodes are host
objects and for..in enumerates the enumerable properties of an object
where host objects are free to define which properties are enumerable
and which not. Thus if for..in with a host object does not enumerate the
properties you are expecting there is nothing you can change in your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top