well, try this and just add the db functionality.
Private Sub SyncStations(ByVal xml As String)
Dim description As String
Dim id As String
Dim record As String
Dim records() As String
Dim stations As String
stations = getSingleSegment("STATIONS", xml)
records = getMultipleSegments("RECORD", stations)
For Each record In records
id = getSingleSegment("ID", record)
description = getSingleSegment("DESCRIPTION", record)
id = getSegmentValue(id)
description = getSegmentValue(description)
MsgBox(id & vbCrLf & description)
Next
End Sub
Private Function getMultipleSegments(ByVal segment As String, ByVal xml
As String) As String()
Dim pattern As String = "<\s*" & segment & "[^>]*>.*?<\s*/\s*" &
segment & "\s*>"
Dim regExp As New Regex(pattern, RegexOptions.Compiled Or
RegexOptions.ExplicitCapture Or RegexOptions.Singleline Or
RegexOptions.IgnoreCase)
If Not regExp.IsMatch(xml) Then Exit Function
Dim match As Match
Dim result() As String
Dim index As Integer
For Each match In regExp.Matches(xml)
ReDim Preserve result(index)
result(index) = match.Value
index += 1
Next
Return result
End Function
Private Function getSingleSegment(ByVal segment As String, ByVal xml As
String) As String
Dim pattern As String = "<\s*" & segment & "[^>]*>.*?<\s*/\s*" &
segment & "\s*>"
Dim regExp As New Regex(pattern, RegexOptions.Compiled Or
RegexOptions.ExplicitCapture Or RegexOptions.Singleline Or
RegexOptions.IgnoreCase)
If Not regExp.IsMatch(xml) Then Exit Function
Dim match As Match = regExp.Match(xml)
Return match.Value
End Function
Private Function getSegmentValue(ByVal xml As String) As String
Dim pattern As String = "<[^>]*>"
Dim regExp As New Regex(pattern)
If Not regExp.IsMatch(xml) Then Exit Function
Return regExp.Replace(xml, "")
End Function