Question : XML in to an ADO Recordset

Hi,

I'm using the code attached to read an XML file in to an ADO recordset. However it doesn't work properly. The field descriptions being shown are part of the 'result created' bit of the XML (which is below the VB).

The record count comes up as '1'. The fields 1,2,3 and 4 come up as '2009-12-08T17:14:48+00:00', 'www.systemmonitor.co.uk', 'OK', and then all of the client information stuck together at once.

The VB works perfectly for another example XML page, i.e. http://www.w3schools.com/XML/cd_catalog.xml. Is there something I need to do to get it working correctly with my XML code?

(the URL in the code has an API key replaced with 'mykey' as it's client sensitive data - the data is generated and is beyond my control so I need to read it differently rather than adjust it).

Thanks in anticipation,

John.
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:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
'****VB Code
Public Function Test()
   Dim adoConn As ADODB.Connection
   Dim adoRS As ADODB.Recordset
 
   Set adoConn = New ADODB.Connection
   Set adoRS = New ADODB.Recordset
 
   adoConn.Open "Provider=MSDAOSP; Data Source=MSXML2.DSOControl.2.6;"
   
   adoRS.Open "http://www.systemmonitor.co.uk/api/?apikey=mykey&service=list_clients", adoConn
 
adoRS.MoveFirst
MsgBox adoRS.RecordCount
MsgBox adoRS.Fields(1)
MsgBox adoRS.Fields(2)
MsgBox adoRS.Fields(3)
MsgBox adoRS.Fields(4)
 
adoRS.Close
 
End Function
 
 
'****XML below:
 
   
- 
- 
- 
  Client 1 
   
   
   
  15648 
  0 
  0 
  
- 
  Client 2 
   
   
   
  15549 
  0 
  0 
  
- 
  Client 3 
   
   
   
  15274 
  0 
  0 
  
- 
  Client 4 
   
   
   
  15282 
  0 
  0 
  
- 
  Client 5 
   
   
   
  15188 
  0 
  0 
  
- 
  Client 6 
   
   
   
  15241 
  0 
  0 
  
- 
  Client 7 
   
   
   
  15246 
  0 
  0 
  
- 
  Client 8 
   
   
   
  15248 
  0 
  0 
  
- 
  Client 9 
   
   
   
  15253 
  0 
  0 
  
- 
  Client 10 
   
   
   
  15254 
  0 
  0 
  
- 
  Client 11 
   
   
   
  15265 
  0 
  0 
  
- 
  Client 12 
   
   
   
  15267 
  0 
  0 
  
- 
  Client 13 
   
   
   
  15268 
  0 
  0 
  
- 
  Client 14 
   
   
   
  15273 
  0 
  0 
  
- 
  Client 15 
   
   
   
  15275 
  0 
  0 
  
- 
  Client 16 
   
   
   
  15277 
  0 
  0 
  
- 
  Client 17 
   
   
   
  15278 
  0 
  0 
  
- 
  Client 18 
   
   
   
  15280 
  0 
  0 
  
- 
  Client 19 
   
   
   
  15281 
  0 
  0 
  
- 
  Client 20 
   
   
   
  15294 
  0 
  0 
  
- 
  Client 21 
   
   
   
  15299 
  0 
  0 
  
- 
  Client 22 
   
   
   
  15306 
  0 
  0 
  
- 
  Client 23 
   
   
   
  15311 
  0 
  0 
  
- 
  Client 24 
   
   
  2009-04-22 
  16129 
  0 
  0 
  
- 
  Client 24 
   
   
  2009-07-13 
  17370 
  0 
  0 
  
- 
  Client 25 
   
   
  2009-09-14 
  18521 
  0 
  0 
  
- 
  Client 26 
   
   
  2009-10-01 
  18927 
  0 
  0 
  
- 
  Client 27 
   
   
  2009-10-01 
  18930 
  0 
  0 
  
  
  

Answer : XML in to an ADO Recordset

For those you need to change:

adoConn.Open "Provider=MSDAOSP; Data Source=MSXML2.DSOControl.2.6;"

to

adoConn.Open "Provider=MSDAOSP; Data Source=MSXML2.DSOControl;"

Basically you remove the requirement to use V2.6 of the Data Source and it will use whatever is present on the machine.

As for MSXML, it is definitely more capable (albeit not my area of expertise) but for your needs here the recordsets seem like a sufficient solution.
Random Solutions  
 
programming4us programming4us