mstarmatt 0 Newbie Poster

So far i have managed to butcher some code i found around 12mth ago to allow me to read the relevant node but i'm struggling to find out how to edit this node value and save the xml file. I cant find where i got this from or anything similar. I expect a lot of the code can be stripped out:

Option Explicit
Dim strXMLFilePath As String
Dim objXMLDOM As New MSXML2.DOMDocument26
Dim objNodes As IXMLDOMNodeList
Dim objBookNode As IXMLDOMNode
Dim objFSO As Object
Dim ObjFile As Variant
Dim ObjFolder As Variant
Dim Nodevalue
Dim Nodevalue1
Dim Appexe1

Private Sub Command1_Click()
Call ReadXMLFiles
End Sub

Sub ReadXMLFiles()
On Error GoTo ErrorHandler ' Enable error-handling routine.
Set objFSO = CreateObject("Scripting.FileSystemObject")
strXMLFilePath = App.Path
If objFSO.FolderExists(strXMLFilePath) Then
Set ObjFolder = objFSO.GetFolder(strXMLFilePath)
For Each ObjFile In ObjFolder.Files
If InStr(ObjFile.Type, "XML") > 0 Then
Call LoadXMLFiles(strXMLFilePath, "system.xml")
Call ReadFile
'FileCopy SourceFile, TargetFile '// If you want to copy from some Different location
'Kill (strXMLFilePath & ObjFile.Name)'// You Can Kill the File if you want after reading
End If
Next
End If

Set ObjFolder = Nothing
Set ObjFile = Nothing
Set objFSO = Nothing
Exit Sub ' Exit to avoid handler.
ErrorHandler: ' Error-handling routine.
Set ObjFolder = Nothing
Set ObjFile = Nothing
Set objFSO = Nothing
End
End Sub

Sub LoadXMLFiles(strXMLFilePath As String, strXMLFileName As String)
On Error GoTo ErrorHandler ' Enable error-handling routine.
objXMLDOM.async = False
objXMLDOM.Load (strXMLFilePath & "\" & strXMLFileName)
Exit Sub ' Exit to avoid handler.
ErrorHandler: ' Error-handling routine.
Set objXMLDOM = Nothing
End
End Sub

Sub ReadFile()
Set objNodes = objXMLDOM.selectNodes("/NewDataSet/System")
For Each objBookNode In objNodes

If objBookNode.selectNodes("WebServiceInternalURL").length <> 0 Then
Appexe1 = objBookNode.selectSingleNode("WebServiceInternalURL").nodeTypedValue
Debug.Print Appexe1
Text1 = (Appexe1)
End If

Next objBookNode
End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.