Question : How to Parse http.ResponseText returned from Web service

I have written a web service with a number of different functions.  One of thes functions returns an ArrayOfString.  I am in process of writing code that access this web service.  The only part I am having trouble with is how to access (parse out) the array elements from the response text or how to assign the ResponseText to an Array.  I am attaching snipet from my web service (The function in question) and a snipet from my vba client that calls the service and receives the ResponseText.  I also attached a text file of the ResponseText.

Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
'################################################################
    '# This Funtion returns string array of road segment that 
    '# matchs Street Name, Type and Location City Zip and with range
    '################################################################

     _
    Public Function GetArray_StreetSegment(ByVal strHnum As String, ByVal strPreDir As String, ByVal strName As String, ByVal strType As String, ByVal strcity As String, ByVal strzip As String) As String()
        Dim RetVal(10) As String
        Dim sqlCommand As String
 
        Dim strSQLcommand As String

        '-- Build the SQL command'

        strSQLcommand = "Select OBJECTID, L_F_ADD,L_T_ADD, R_F_ADD, R_T_ADD, predir, stname, sttype, locationcity, zip  from " & MyTable & " Where (("

        If strPreDir = "" Then
            strSQLcommand = strSQLcommand & "(predir = '' or predir is null)"
        Else
            strSQLcommand = strSQLcommand & "predir ='" & strPreDir & "'"
        End If
        strSQLcommand = strSQLcommand & " And StName ='" & strName & "'"

        If strType = "" Then
            strSQLcommand = strSQLcommand & " And (stType ='' or stType is null)"
        Else
            strSQLcommand = strSQLcommand & " And sttype ='" & strType & "'"
        End If
        strSQLcommand = strSQLcommand & " And LocationCity ='" & strcity & "'"
        strSQLcommand = strSQLcommand & " And Zip ='" & strzip & "') "
        strSQLcommand = strSQLcommand & " And (((L_F_ADD >=" & strHnum & " AND L_T_ADD <=" & strHnum & ")" & _
            " Or (L_F_ADD <=" & strHnum & " AND L_T_ADD >=" & strHnum & ")) Or " & _
            " ((R_F_ADD >= " & strHnum & " and R_T_ADD <= " & strHnum & ") Or  " & _
            " (R_F_ADD <= " & strHnum & "  and R_T_ADD >= " & strHnum & "))))"


        sqlCommand = strSQLcommand

        ' The data referenced is accessed through a MultiVersioned View (ESRI SDE terminology)

        Dim VersionCommand1 As New SqlCommand("sde.set_current_version", connection)
        VersionCommand1.CommandType = CommandType.StoredProcedure
        VersionCommand1.Parameters.Add("@version_name", NVarChar, 25)
        VersionCommand1.Parameters("@version_name").Value = MyVersion
        connection.Open()
        VersionCommand1.ExecuteNonQuery()

        Dim adapter As SqlDataAdapter = New SqlDataAdapter(sqlCommand, connection)
        Dim custDS As DataSet = New DataSet()

        adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
        adapter.Fill(custDS, MyTable)
        '-- Should only be one record that matches if any so only look at 0
        If custDS.Tables(0).Rows.Count > 0 Then
            RetVal(0) = custDS.Tables(0).Rows(0).Item(0).ToString
            RetVal(1) = custDS.Tables(0).Rows(0).Item(1).ToString
            RetVal(2) = custDS.Tables(0).Rows(0).Item(2).ToString
            RetVal(3) = custDS.Tables(0).Rows(0).Item(3).ToString
            RetVal(4) = custDS.Tables(0).Rows(0).Item(4).ToString
            RetVal(5) = custDS.Tables(0).Rows(0).Item(5).ToString
            RetVal(6) = custDS.Tables(0).Rows(0).Item(6).ToString
            RetVal(7) = custDS.Tables(0).Rows(0).Item(7).ToString
            RetVal(8) = custDS.Tables(0).Rows(0).Item(8).ToString
            RetVal(9) = custDS.Tables(0).Rows(0).Item(9).ToString
        Else
            RetVal(0) = "False"
        End If

        Return RetVal

    End Function

Answer : How to Parse http.ResponseText returned from Web service

Not sure how to implement the xml parser examples in vba.  What I was hoping for was some simple way of loading an xml object with the xml data and then getting the attributes.  But I can't find an example that works (at least in vba).  

What I ended up doing was just creating a function called GetStringAttributes and passing it the xml string.  The code I used is below and it returns a string array of 10 elements.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
'#########################################################
'# Function to parse out xml response from the
'# GetArray_StreetSegment web service call
'# returns a string array
'#########################################################

Private Function GetStringAttributes(refstring As String) As String()
    Dim answer(9) As String
    Dim s As Integer
    Dim x As Integer
    Dim y As Integer
    Dim i As Integer
    x = 0
    y = 0
    s = 1
    
    For i = 0 To 9
        x = InStr(s, refstring, "")
        y = InStr(s, refstring, "")
        If y > x Then
            answer(i) = ""
            s = x
        Else
            answer(i) = Mid$(refstring, (y + 8), ((x - y) - 8))
            s = x + 8
        End If
        
    Next
    GetStringAttributes = answer
  
End Function
Random Solutions  
 
programming4us programming4us