473,810 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ 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(originaln ode.Attributes( "start_time").V alue, DateTime)
OldEndTime =
CType(originaln ode.Attributes( "end_time").Val ue, DateTime)
Dim OldType As String =
originalnode.At tributes("type" ).Value
Dim OldId As Integer =
CType(originaln ode.Attributes( "staff_attendan ce_id").Value, Integer)

If NewStartTime < OldEndTime AndAlso NewEndTime >
OldEndTime AndAlso NewStartTime > OldStartTime Then
'adjust end time of original
originalnode.At tributes("end_t ime").Value =
NewStartTime.To String("yyyy-MM-dd HH:mm")
m_XmlModified = True

ElseIf NewStartTime < OldStartTime AndAlso NewEndTime <
OldEndTime AndAlso NewEndTime > OldStartTime Then
'adjust start time of original
originalnode.At tributes("start _time").Value =
NewEndTime.ToSt ring("yyyy-MM-dd HH:mm")
m_XmlModified = True

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

ElseIf NewStartTime > OldStartTime AndAlso NewEndTime <
OldEndTime Then
'split the original item by adjusting the end time of
the original
originalnode.At tributes("end_t ime").Value =
NewStartTime.To String("yyyy-MM-dd HH:mm")

'and then insert a new item at the end
Me.xmlInsertAtt endanceNode(Sta ffName, 0, NewEndTime,
OldEndTime, OldType)

End If

Next

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

Jan 24 '06 #1
1 1401
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.Cou nt)
xmlOther.Remove Child(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
4295
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 att="c">s5</item>
2
2781
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 that refers to them. I suppose I can imagine cases where this idea would be useful, but I can imagine many more where I'd like to get a *static* list of, e.g., the <p> elements in my document, and do something with them, regardless of any I...
3
2025
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 lack of W3C support. All I know is, that this Xsl document works with the current implementation of MSXML V4.0 SP2 if transformed using e.g. VB6. I'm told by the compiler at runtime, that "the expression should evaluate to a nodeset" (the...
8
4242
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: I load xml via httpwebrequest etc and put it in a XmlDocument. xmlFeed.Load(xRes.GetResponseStream()); This works fine as i can use this stream with a XmlReader to parse the
2
1655
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. Does anyone know of a way to do this without looping through foreach (node in nodelist) ? Thanks you
2
3567
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 where I know how to do this. In .NET I am starting to get crazy because I don´t manage to transform my nodelist into an XPath-Navigable-Document. Can Anybody please help me?
2
5067
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 every case except if the pNd is the NodeList at which point I end up with the nodeList in the first element of the array instead of acting like the array would. function doSomething(pNd){ if(pNd.constructor != Array){pNd = new Array(pNd)}...
0
1327
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 suggest me improvements. Please tell me if there is an easier way of finding the height of a BST by iteration. Thanks
15
5790
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 into NodeList because of Firefox if (!Object.getElementsByTagName && Object.length) { Object.prototype.getElementsByTagName = function(name) { // the only idea I got var div = document.createElement("div");
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10124
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.