Mega Code Archive

 
Categories / VisualBasic Script / XML
 

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