MSXML DOM Appending child nodes


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: MSXML DOM Appending child nodes

  1. #1
    Niklas Guest

    MSXML DOM Appending child nodes


    Hi!

    I'm using DOM in an Visual Basic environment. My problem is that I want to
    append childnodes to the parents of the nodes I have in a nodelist. When
    I am debugging my source code I can see that new nodes are inserted at the
    right place but when the next node in the for loop is to be inserted, the
    previous inserted node disappear..! In other words, only the last node in
    the for loop is included in the DOMDocument.

    Code:

    Set objCarryOver = objContext.selectNodes("descendant::alt[attribute:rofile='440.1991.2.83']")
    For i = 0 To objCarryOver.length - 1
    Set objParentNode = objCarryOver(i).parentNode
    objParentNode.appendChild objNode
    oDoc.save (App.Path & "\latsource01x.xml")
    Next i

    Thanks in advance // Niklas

  2. #2
    Slavomir Kundrik Guest

    Re: MSXML DOM Appending child nodes

    Niklas,
    if I understand correctly what you want to do try this:

    Dim objNode as MSXML2.IXMLDOMNode
    Set objCarryOver =
    objContext.selectNodes("descendant::alt[attribute:rofile='440.1991.2.83']"
    )
    For Each objNode In objCarryOver
    objParentNode.appendChild objNode.Clone(True)
    Next

    Slavomir Kundrik

    P.S. I love Volvo cars.

    "Niklas" <niklas.e.wennberg@consultant.volvo.com> wrote in message
    news:3a814b45$1@news.devx.com...
    >
    > Hi!
    >
    > I'm using DOM in an Visual Basic environment. My problem is that I want to
    > append childnodes to the parents of the nodes I have in a nodelist. When
    > I am debugging my source code I can see that new nodes are inserted at the
    > right place but when the next node in the for loop is to be inserted, the
    > previous inserted node disappear..! In other words, only the last node in
    > the for loop is included in the DOMDocument.
    >
    > Code:
    >
    > Set objCarryOver =

    objContext.selectNodes("descendant::alt[attribute:rofile='440.1991.2.83']"
    )
    > For i = 0 To objCarryOver.length - 1
    > Set objParentNode = objCarryOver(i).parentNode
    > objParentNode.appendChild objNode
    > oDoc.save (App.Path & "\latsource01x.xml")
    > Next i
    >
    > Thanks in advance // Niklas




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center