Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











METHOD:  Object::removeChild

Object  Attr   CDATASection   CharacterData   Comment   Document   DocumentFragment   DocumentType   Entity   EntityReference   Node   Notation   ProcessingInstruction   Text
 
Object.removeChild(oldChild)

The removeChild method removes the specified node from the list of children and returns it.

Using the 'names.xml' file the following example removes the third 'name' element (Charlie) from the NodeList of the root element's children and appends it to the end. The code then iterates through the Node collection displaying the value of the first child (the text node) of each.

XML:
<names>
   <name>Alice</name>
   <name>Bert</name>
   <name>Charlie</name>
   <name>Diane</name>
   <name>Eric</name>
</names>

Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("names.xml")

Set objRoot = objXMLDoc.documentElement
Set objExNode = objRoot.removeChild(objRoot.childNodes.item(2))
objRoot.appendChild(objExNode)

Set objNodeList = objXMLDoc.getElementsByTagName("name")
For Each elem in objNodeList
   document.write(elem.firstChild.nodeValue & "<br>")
Next

Output:
Alice
Bert
Diane
Eric
Charlie



 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information