Assuming that the wt.txt file looks like this (separate lines) ….
<SizeClassificationReport Start="2018-04-27T12:33:52.903+01:00" End="2018-04-27T12:34:53.993+01:00" TimePeriod="1" xmlns="ICDNAV001-SizeClassificationReport">
<Classifications>
<Classification
CarriageWayId="1"
LaneId="0"
SectionId="17800"
Classification="Combination"
Count="0"
AverageSize="1234"
AverageSpeed="0"
/>
<Classification
CarriageWayId="1"
LaneId="0"
SectionId="17800"
Classification="Long"
Count="0"
AverageSize="0"
AverageSpeed="0"
/>
… something like this might be easier, but ...
Sub test2()
MsgBox getString()
End Sub
Public Function getString() As String
Dim myFSO As New Scripting.FileSystemObject
Dim path As String
Dim fileName As String
Dim testStr As String
Dim v As Variant
path = Environ("USERPROFILE") & "\Desktop\"
fileName = "wt.txt"
testStr = "AverageSize"
Set FSO = myFSO.OpenTextFile(path + fileName)
Do Until FSO.AtEndOfStream
txt = Trim(FSO.ReadLine)
If Len(txt) > 0 Then
v = Split(txt, "=")
If v(0) = testStr Then
getString = v(1)
Exit Function ' delete to keep on going
End If
End If
Loop
FSO.Close
End Function
… since your "AverageSpeed" occurs multiple times in the file, I'm not sure how you want to handle them