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

RemoveChild

Hi

What can next problem:

'Code
For Each oNode in oParent.ChildNodes
oParent.RemoveChild(oNode)
Next

Problem: Only first child node is removed!

Best regadrs;
Mex

May 30 '07 #1
5 1423


Hi Mex,
You are modifying the collection you are enumerating, which is not a good
idea.

Is there something wrong with oParent.Clear()?
Robin
May 30 '07 #2

ehh of course, forgot about enum :))

solution is

'Remove child nodes
For i As Integer = oParent.ChildNodes.Count - 1 To 0 Step -1
oParent.RemoveChild(oParent.ChildNodes(i))
Next

Mex
"Robin Tucker" <rt******@hotmail.comwrote in message
news:f3*******************@news.demon.co.uk...
>

Hi Mex,
You are modifying the collection you are enumerating, which is not a good
idea.

Is there something wrong with oParent.Clear()?
Robin


May 30 '07 #3

Maybe a little tidier:
While oParent.ChildNodes.Count 0
oParent.ChildNodes.RemoveAt (0)
End While
but I still prefer:

oParent.ChildNodes.Clear()


"Meelis Lilbok" <me***********@deltmar.eewrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
>
ehh of course, forgot about enum :))

solution is

'Remove child nodes
For i As Integer = oParent.ChildNodes.Count - 1 To 0 Step -1
oParent.RemoveChild(oParent.ChildNodes(i))
Next

Mex
"Robin Tucker" <rt******@hotmail.comwrote in message
news:f3*******************@news.demon.co.uk...
>>

Hi Mex,
You are modifying the collection you are enumerating, which is not a good
idea.

Is there something wrong with oParent.Clear()?
Robin



May 30 '07 #4
there is no method like ChildNodes.Clear()

Mex

"Robin Tucker" <rt******@hotmail.comwrote in message
news:f3*******************@news.demon.co.uk...
>
Maybe a little tidier:
While oParent.ChildNodes.Count 0
oParent.ChildNodes.RemoveAt (0)
End While
but I still prefer:

oParent.ChildNodes.Clear()


"Meelis Lilbok" <me***********@deltmar.eewrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
>>
ehh of course, forgot about enum :))

solution is

'Remove child nodes
For i As Integer = oParent.ChildNodes.Count - 1 To 0 Step -1
oParent.RemoveChild(oParent.ChildNodes(i))
Next

Mex
"Robin Tucker" <rt******@hotmail.comwrote in message
news:f3*******************@news.demon.co.uk...
>>>

Hi Mex,
You are modifying the collection you are enumerating, which is not a
good idea.

Is there something wrong with oParent.Clear()?
Robin




May 30 '07 #5
My mistake, all story is about XML :))

Mex

"Meelis Lilbok" <me***********@deltmar.eewrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
Hi

What can next problem:

'Code
For Each oNode in oParent.ChildNodes
oParent.RemoveChild(oNode)
Next

Problem: Only first child node is removed!

Best regadrs;
Mex

May 30 '07 #6

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

Similar topics

2
by: bulk88 | last post by:
How can I emulate DOM level 1 removeChild in IE 4? I already figured out to emulate getElementById by doing this if((!document.getElementById) && document.all) {document.getElementById =...
1
by: JehanNYNJ | last post by:
I need to clear out the HTML contents of a <span> element and then re-add that element as a blank span. Here is the code... var elem = document.getElementById(spanId); var deletedElem =...
8
by: Enzo | last post by:
Hi, I have a <div> created dynamically with 'appendchild', inside it a form. When I press the 'esc' key, inside the <div>, I need to remove them and return to the parent page. Using...
2
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
5
by: Markus Stehle | last post by:
Hi all! I want to remove a node from a nodelist by using RemoveChild. I'm using the following code: XmlNode root = Xml.DocumentElement; XmlNodeList items = root.SelectNodes("Item"); XmlNode...
1
by: Rebecca Tsukalas | last post by:
Hello, I have a problem concerning removeChild. This is the XML structure I use with php: <xml_thing <language1 <site>bla1</site <site>bla2</site <site>bla3</site </language1
6
by: VK | last post by:
I must be missing something very obvious, but my nightly head doesn't work anymore. Press "Insert" button to add <insnodes after each <br>. Now press "Delete" - only even <insare being removed....
5
by: tader | last post by:
Hi, so i got script like that var div_box = document.createElement("div"); div_box.setAttribute("id", "music_box"); div_box.style.top = (Number(cords) - 10) + "px"; div_box.style.left =...
10
by: r_ahimsa_m | last post by:
Hello, On index.html page I have a table with id="property_fields". <table id="property_fields" name="property_fields" border="0"> It contains set of rows with the following IDs: var...
5
by: r_ahimsa_m | last post by:
Hello, I am lerning HTML/CSS/JavaScript. I created HTML page with table "property_fields" containing 24 rows ('tr' elements). I want to remove last 23 rows: var table =...
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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.