Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

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.
0
lutt
Asked:
lutt
  • 4
  • 2
1 Solution
 
dfiala13Commented:
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


0
 
luttAuthor Commented:
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.
0
 
dfiala13Commented:
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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dfiala13Commented:
sorry have C# on the brain. Should be..,

for i = 1 to nl.Count
 console.write(nl(i).nodename)
next
0
 
luttAuthor Commented:
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.
0
 
dfiala13Commented:
I have no idea.  Nothing I can find at MS and it works fine in 4.0 which is what I have running.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now