Hello guys I got this code to modify some XML data,
I have no hardcoded the filepath,
Could someone help me to modify my code, add a Dialogwindow so I select a folder then the script loops through all .xml files
here is my code
Sub xmlAddValues()
Dim analyse
Dim exactContexts
Dim subnode
Dim repeated
Dim realRepeated
Dim tmpValue
Set analyse = CreateObject("Msxml2.DOMDocument.6.0")
analyse.Load "C:\test\example.xml" ' HERE IS HARDCODED
Set exactContexts = analyse.SelectNodes("//inContextExact")
For i = 0 To exactContexts.Length - 1
Set subnode = exactContexts(i)
For Each att In subnode.Attributes
If att.Name = "words" Then
att.Value = "0"
Exit For
End If
Next att
Next i
Set repeated = analyse.SelectNodes("//crossFileRepeated")
For i = 0 To repeated.Length - 1
Set subnode = repeated(i)
For Each att In subnode.Attributes
If att.Name = "words" Then
tmpValue = att.Value
att.Value = "0"
Exit For
End If
Next att
Set realRepeated = subnode.NextSibling
For Each att In realRepeated.Attributes
If att.Name = "words" Then
att.Value = Val(att.Value) + Val(tmpValue)
Exit For
End If
Next att
Next i
analyse.Save "C:\test\Example.xml" ' HERE IS HARDCODED
End Sub
Thank you in advance
Bookmarks