Parse XML


Public Function fParseXML(sTag01 As String, sTag02 As String, sToParse As String) As String
 Dim pStart As Integer
 Dim pEnd As Integer
 Dim pLen As Integer
 If InStr(1, sToParse, sTag01) Then
  pStart = InStr(1, sToParse, sTag01) + Len(sTag01)
  pEnd = InStr(pStart, sToParse, sTag02)
  pLen = pEnd - pStart
  fParseXML = Mid(sToParse, pStart, pLen)
  Exit Function
 Else
  fParseXML = "Not found" & "**" & sTag01 & "**" & Mid(sToParse, 1, 100)
  Exit Function
 End If
End Function

'Usage:

Sub TestIt()
 ' "F) GND G) FL240)"
 MsgBox "**" + fParseXML("F)", "G)", "F) GND G) FL240)") + "**"
 MsgBox "**" + fParseXML("G)", ")", "F) GND G) FL240)") + "**"
End Sub