473,493 Members | 3,174 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

NodeList iteration and node edit

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

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

Jan 24 '06 #1
1 1391
Yup, I have a bug post here:

http://lab.msdn.microsoft.com/produc...a-06ef839bd322

You essentially have to do a count of the number of nodes then iterate
it through using it as if it were an array. Here is what I had to do
using this...

For i As Int16 = 1 To CShort(xmlOther.ChildNodes.Count)
xmlOther.RemoveChild(xmlOther.ChildNodes(0))
Next

Josh

Jan 25 '06 #2

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

Similar topics

2
4279
by: Angus McIntyre | last post by:
Can this be done with XPath? I have input XML that is basically of the form: <list> <item att="a">s1</item> <item att="a">s2</item> <item att="b">s3</item> <item att="c">s4</item> <item...
2
2753
by: Howard Jess | last post by:
Given the html at the end of this message, I see how a DOM NodeList exhibits its "live" behavior; that is, adding elements to a document can change any NodeList variables, when there's *no* code...
3
2006
by: Anders Borum | last post by:
Hello! I've come across a strange error that occurs, when you try to return a nodelist from a variable with a choose/where/otherwise statement. I'm not quite sure whether it's a bug or simply...
8
4227
by: Øyvind Jægtnes | last post by:
I'm playing around a bit with XPath and nodelist and i want to extract some info from a RSS feed. The one that i am testing at can be viewed at http://slashdot.org/index.rss Ok.. heres the deal:...
2
1644
by: Susan | last post by:
I need to go to a specific node in a XmlNodeList by its number (I know that I want the 5th node in the list, but I do not know any information about the element or attributes contained at the node....
2
3549
by: Chucker | last post by:
Hi folks, I would like to select some nodes from a very large XML document and then apply a stylesheet to the dom fragment / nodelist that is the result of my XPath-Query. I used to use MSXML...
2
5051
by: carlback | last post by:
I have a function were the input parameter can either be an string,array,dom node or NodeList (getElementsByTagName()) and I have somthing like this function which works great for what I want in...
0
1302
by: subramanian100in | last post by:
I have given below the structures and the function that finds the height of a BST by iteration. I have tested the function for several input sets and it is working. Kindly review the code and...
15
5742
Dormilich
by: Dormilich | last post by:
I’m trying to do the following document.getElementsByTagName("sup").getElementsByTagName("a"); currently I have this because I somehow need to return a combined result NodeList // can’t prototype...
0
7119
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
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,...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.