NodeList iteration and node edit

C

Cuperman

I am iterating through a nodelist, and trying to edit node attributes
based on conditions that are met.

As soon as the first condition is met, the For Next loop finishes, even
when there are more nodes left in the list, so subsequent updates are
not completed.

Any one know what causes this?

My loop code is included

Thanks, Mark

==========================================

For Each originalnode As XmlNode In nodelist

Dim OldStartTime, OldEndTime As DateTime
OldStartTime =
CType(originalnode.Attributes("start_time").Value, DateTime)
OldEndTime =
CType(originalnode.Attributes("end_time").Value, DateTime)
Dim OldType As String =
originalnode.Attributes("type").Value
Dim OldId As Integer =
CType(originalnode.Attributes("staff_attendance_id").Value, Integer)

If NewStartTime < OldEndTime AndAlso NewEndTime >
OldEndTime AndAlso NewStartTime > OldStartTime Then
'adjust end time of original
originalnode.Attributes("end_time").Value =
NewStartTime.ToString("yyyy-MM-dd HH:mm")
m_XmlModified = True

ElseIf NewStartTime < OldStartTime AndAlso NewEndTime <
OldEndTime AndAlso NewEndTime > OldStartTime Then
'adjust start time of original
originalnode.Attributes("start_time").Value =
NewEndTime.ToString("yyyy-MM-dd HH:mm")
m_XmlModified = True

ElseIf NewStartTime < OldStartTime AndAlso NewEndTime >
OldEndTime Then
'delete original
xmlDeleteAttendanceNode(OldId)

ElseIf NewStartTime > OldStartTime AndAlso NewEndTime <
OldEndTime Then
'split the original item by adjusting the end time of
the original
originalnode.Attributes("end_time").Value =
NewStartTime.ToString("yyyy-MM-dd HH:mm")

'and then insert a new item at the end
Me.xmlInsertAttendanceNode(StaffName, 0, NewEndTime,
OldEndTime, OldType)

End If

Next

===========================================
 

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
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top