NodeList iteration and node edit

Discussion in 'ASP .Net' started by Cuperman, Jan 24, 2006.

  1. Cuperman

    Cuperman Guest

    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

    ===========================================
    Cuperman, Jan 24, 2006
    #1
    1. Advertising

  2. Cuperman

    Guest

    , Jan 25, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,399
  2. Erwan
    Replies:
    0
    Views:
    614
    Erwan
    Oct 20, 2004
  3. Angus McIntyre
    Replies:
    2
    Views:
    573
    Angus McIntyre
    Sep 4, 2003
  4. Tjerk Wolterink
    Replies:
    2
    Views:
    1,399
    Dimitre Novatchev
    Aug 24, 2006
  5. Rudi
    Replies:
    5
    Views:
    4,963
Loading...

Share This Page