Find and Edit the Node that Contains the FirstName Mike : DOMDocument « XML « VBA / Excel / Access / Word






Find and Edit the Node that Contains the FirstName Mike

 
Sub ChangeNode()
         Dim oXmlDoc As DOMDocument
         Dim oXmlNode As IXMLDOMNode
         FileCopy ThisWorkbook.Path & "\EmployeeSales.xml", _
         ThisWorkbook.Path & "\EmployeeSalesTest.xml"
         Set oXmlDoc = New DOMDocument
         oXmlDoc.async = False
         oXmlDoc.Load (ThisWorkbook.Path & "\EmployeeSalesTest.xml")
         Set oXmlNode = oXmlDoc..SelectsingleNode ("//FirstName[text()='Mike']")
         oXmlNode.Text = "Michael"
         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 Delete all Nodes for the Employee Bullen