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

removed child breaks a for loop

in the following code

For Each child In nodeFarm.ChildNodes
For Each oAttribute In child.Attributes
If oAttribute.Name = "LastUpdated" Then
lastUpdate = oAttribute
End If
Next

If DateDiff(DateInterval.Day, Date.Parse(Today),
Date.Parse(lastUpdate.Value)) < 0 Then
parentnode = child.ParentNode
parentnode.RemoveChild(child)
End If
End If
Next

whenever a child is removed the loop stops and doesn't enumerate any
more children.

what have i done wrong here , should i be doing something else after
removing the child.

glenn
Nov 12 '05 #1
1 1229


Glenn M wrote:
in the following code

For Each child In nodeFarm.ChildNodes
For Each oAttribute In child.Attributes
If oAttribute.Name = "LastUpdated" Then
lastUpdate = oAttribute
End If
Next

If DateDiff(DateInterval.Day, Date.Parse(Today),
Date.Parse(lastUpdate.Value)) < 0 Then
parentnode = child.ParentNode
parentnode.RemoveChild(child)
End If
End If
Next

whenever a child is removed the loop stops and doesn't enumerate any
more children.

what have i done wrong here , should i be doing something else after
removing the child.


DOM collections like ChildNodes are live meaning when you remove a node
from the document the collection changes directly messing up any attempt
to iterate over the collection.
It might suffice to use
while nodeFarm.HasChildNodes
set child = nodeFarm.FirstChild
instead of the for each iteration loop to avoid the problem.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
I need my textbox to work more smoothly with respect to line breaks. When I have data pulled from the database into a textbox there are hard line breaks at the end of each line (by definition how...
7
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. ...
8
by: Edwinah63 | last post by:
Hi Everyone, in vb6 i was able to execute the following code and it would close the children is the reverse order they were opened eg the last child opened was the first child to close. in...
2
by: Lenster | last post by:
Environment --------------- Visual Studio.NET 2003 Version 7.1.3088 ..NET Framework 1.1 Version 1.1.4322 SP1 XP Professional 5.1.2600 SP2 Build 2600 Problem Description...
2
by: daz_oldham | last post by:
Hi everyone An easy one I think, I am just not too sure of the best way of going about this. I have the following XmlNode as an example: <people group="33" status="334kdnsfins435" value"x">...
2
by: sunil | last post by:
Hi All, I am tring to debug the following program.I written this program in HP-Unix and I am using the GDB as a debugger. #include <stdio.h> #include<unistd.h> int main() { int pid; pid =...
2
by: Catch_22 | last post by:
Hi, I have a stored procedure that has to extract the child records for particular parent records. The issue is that in some cases I do not want to extract all the child records only a...
3
by: jismon | last post by:
Hi, I have one problem when i'm trying to loop thorugh the child nodes in a XML string in JAVA. The first Loop is working but in the child node there i want to loop and get the values but it doesn't...
9
by: anon.asdf | last post by:
Hi! The following code is a snippet where the goto's cannot be removed "without increasing code-size, or decreasing performance". /*********A**************/ int var_other_thread; // value...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.