Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert XML String to ADO Recordset

Status
Not open for further replies.

dvrobin

Programmer
Jun 4, 2001
40
US
I can't believe that I can't find this information anywhere. Hopefully someone has run into this before. I have an xml string that I want to convert to an ADO recordset, so I can use a hierarchical flexgrid for display. The file is of the following format:


<Top_Root>
<Field1>
value1
</Field1>
</Top_Root>


I found the following code on Microsoft's website, but it gives me an error stating that the XML is invalid, but I know it's good XML.


'**************************
Dim rs As ADODB.Recordset
Dim stm As ADODB.Stream

Set rs = New Recordset
Set stm = New ADODB.Stream
stm.Open ' Open a stream object

stm.Charset = &quot;iso-8859-1&quot; ' character set strings code for ANSI, ASCII
'Load a Stream object from the XML file
stm.LoadFromFile &quot;C:\test.xml&quot;

' Uncommenting the connection string in the following line generates error 3001
rs.Open stm ', &quot;Provider=MsPersist&quot;


Any and all help is appreciated.
Dave Robinder, MCSD
Programmer
Colorado DataScapes
Colorado Springs, CO
(719) 328-1111
 
good xml?
that depends on your purpose.
Problem with your xml is it doesn't have all the attributes so that ADO can reform the recordset. IE what the column attributes are.
 
It seems to me that ADO is not actually supporting XML, but rather a subset of XML that follows strict schema guidelines. Unfortunately, that's next to worthless for my purposes.

Is there an easy way to programmatically transform the XML I receive (in the example above) and make it look like something that ADO can recognize. I've seen similar questions to this before, but nobody seems to have an answer.

I won't necessarily know what the XML fields will be before I need to create the display. I need to be able to take any XML string and convert into an ADO recordset.
Dave Robinder, MCSD
Consultant
Booz Allen Hamilton
Colorado Springs, CO
(719) 590-6041
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top