Link to home
Start Free TrialLog in
Avatar of lutt
lutt

asked on

xml nodelist problem

I have this code:

for each IXMLDOMNode in IXMLDOMNodelist
  console.write(IXMLDOMNode.nodename)
next

why it gives an infinite loop showing only the first nodename in the nodelist? Confused. The nodelist contains more than one node. Thanks.
Avatar of dfiala13
dfiala13

that's because you are using the class name

try this...
Dim n as IXMLDOMNode
for each n in IXMLDOMNodelist
  console.write(n.nodename)
next


Avatar of lutt

ASKER

I just want to show it is a node type.
I did just as what you suggested. By the way, I use MSXML3.0 in .NET.
Why not just use a conventional for loop

dim i as integer
dim nl  as IXMLDOMNodeList

for i = 1 to nl.Count
 console.write(nl[i].nodename)
next

Also consider upgrading to v4.  It's possble there is something wrong with v3 in this area.
sorry have C# on the brain. Should be..,

for i = 1 to nl.Count
 console.write(nl(i).nodename)
next
Avatar of lutt

ASKER

The conventional loop did work, but why for each loop doesn't work?
some examples use for each loop. Could you give more detail why for each loop doesn't work? Thanks.
ASKER CERTIFIED SOLUTION
Avatar of dfiala13
dfiala13

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial