Find and Delete all Nodes for the Employee Bullen : DOMDocument « XML « VBA / Excel / Access / Word






Find and Delete all Nodes for the Employee Bullen

 
Sub DeleteNode()
           Dim oXmlDoc As DOMDocument
           Dim oXmlNode As IXMLDOMNode
           Dim oXmlNodes As IXMLDOMNodeList
           Set oXmlDoc = New DOMDocument
           oXmlDoc.async = False
           oXmlDoc.Load (ThisWorkbook.Path & "\EmployeeSalesTest.xml")

           Set oXmlNodes = oXmlDoc.SelectNodes("//Employee[LastName='Bullen']")
           For Each oXmlNode In oXmlNodes
           oXmlNode.parentnode.RemoveChild oXmlNode
           Next
           oXmlDoc.Save ThisWorkbook.Path & "\EmployeeSalesTest.xml"
End Sub

 








Related examples in the same category

1.Find by path
2.Find by value
3.Find by string value
4.Find and Edit the Node that Contains the FirstName Mike