RemoveNode()

Top  Previous  Next

Method

RemoveNode(oNode)

Parameters

oNode (object, MSXML DOM Node) The node you wish to remove from the document

Returns

Boolean

Example

See Below.  The RemoveNode() method returns True on Success

 

 

Example VBScript Code

 

Private Sub DemoXML()

 

Dim oXML, ndRoot, ndList

Dim sBuff, i

 

'Create the object

Set oXML = oUTILITIES.NewCommandoXMLObject()

 

'Using the With / End With statements make for easy shortcuts

With oXML

   'Open an XML File

   If Not .OpenFromFile(oUTILITIES.ApplicationPath & "MyFileName.XML") Then

     SMEvent.Raise "ERROR", "XML File Open Failed"

   End If

    Set ndRoot = .GetRootElement()   

   If .HasChildren(ndRoot) Then 

     Set ndList = .GetRootChildren()

     'NOTE: ndRoot is just an MS XML Dom Node so this would also work:

     'Set ndList = ndRoot.ChildNodes

     MsgBox "The root element has " & ndList.Length & " Child Nodes"

     'Show the XML

      MsgBox .XML, vbInformation, "XML Before RemoveNode()"

       'A DOM Node List is a 0 based collection

     If Not .RemoveNode(ndList(0)) 

      SMEvent.Raise "ERROR", "XML RemoveNode Failed"   

     End If     

     'Show the XML

      MsgBox .XML, vbInformation, "XML Now has 1st Child Node Removed"

   End If    End With

'Clean up the objects

Set ndRoot = Nothing

Set ndList = Nothing

Set oXML = Nothing

 

End Sub

 

See Also: oUTILITIES.NewCommandoXMLObject()