RemoveChild

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Meelis Lilbok

    #1

    RemoveChild

    Hi

    What can next problem:

    'Code
    For Each oNode in oParent.ChildNo des
    oParent.RemoveC hild(oNode)
    Next

    Problem: Only first child node is removed!

    Best regadrs;
    Mex



  • Robin Tucker

    #2
    Re: RemoveChild



    Hi Mex,


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

    Is there something wrong with oParent.Clear() ?


    Robin


    Comment

    • Meelis Lilbok

      #3
      Re: RemoveChild


      ehh of course, forgot about enum :))

      solution is

      'Remove child nodes
      For i As Integer = oParent.ChildNo des.Count - 1 To 0 Step -1
      oParent.RemoveC hild(oParent.Ch ildNodes(i))
      Next

      Mex


      "Robin Tucker" <rtgroups@hotma il.comwrote in message
      news:f3jlja$hcu $1$8302bc10@new s.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
      >
      >

      Comment

      • Robin Tucker

        #4
        Re: RemoveChild


        Maybe a little tidier:


        While oParent.ChildNo des.Count 0
        oParent.ChildNo des.RemoveAt (0)
        End While


        but I still prefer:

        oParent.ChildNo des.Clear()




        "Meelis Lilbok" <meelis.lilbok@ deltmar.eewrote in message
        news:umsnI7qoHH A.5052@TK2MSFTN GP04.phx.gbl...
        >
        ehh of course, forgot about enum :))
        >
        solution is
        >
        'Remove child nodes
        For i As Integer = oParent.ChildNo des.Count - 1 To 0 Step -1
        oParent.RemoveC hild(oParent.Ch ildNodes(i))
        Next
        >
        Mex
        >
        >
        "Robin Tucker" <rtgroups@hotma il.comwrote in message
        news:f3jlja$hcu $1$8302bc10@new s.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
        >>
        >>
        >
        >

        Comment

        • Meelis Lilbok

          #5
          Re: RemoveChild

          there is no method like ChildNodes.Clea r()

          Mex



          "Robin Tucker" <rtgroups@hotma il.comwrote in message
          news:f3jopr$eue $1$8300dec7@new s.demon.co.uk.. .
          >
          Maybe a little tidier:
          >
          >
          While oParent.ChildNo des.Count 0
          oParent.ChildNo des.RemoveAt (0)
          End While
          >
          >
          but I still prefer:
          >
          oParent.ChildNo des.Clear()
          >
          >
          >
          >
          "Meelis Lilbok" <meelis.lilbok@ deltmar.eewrote in message
          news:umsnI7qoHH A.5052@TK2MSFTN GP04.phx.gbl...
          >>
          >ehh of course, forgot about enum :))
          >>
          >solution is
          >>
          >'Remove child nodes
          >For i As Integer = oParent.ChildNo des.Count - 1 To 0 Step -1
          > oParent.RemoveC hild(oParent.Ch ildNodes(i))
          >Next
          >>
          >Mex
          >>
          >>
          >"Robin Tucker" <rtgroups@hotma il.comwrote in message
          >news:f3jlja$hc u$1$8302bc10@ne ws.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
          >>>
          >>>
          >>
          >>
          >
          >

          Comment

          • Meelis Lilbok

            #6
            Re: RemoveChild

            My mistake, all story is about XML :))

            Mex



            "Meelis Lilbok" <meelis.lilbok@ deltmar.eewrote in message
            news:uKWA5zooHH A.4124@TK2MSFTN GP02.phx.gbl...
            Hi
            >
            What can next problem:
            >
            'Code
            For Each oNode in oParent.ChildNo des
            oParent.RemoveC hild(oNode)
            Next
            >
            Problem: Only first child node is removed!
            >
            Best regadrs;
            Mex
            >
            >
            >

            Comment

            Working...