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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert XML to ADO Recordset?

Status
Not open for further replies.

kloner

Programmer
May 15, 2000
79
AU
Hi all,

Can someone let me know how you would do this?

Regards,
kloner


 
Well,

You could try the following:

Create a recordset that represents the one you would like to create with xmldata and save the recordset to an xml file. This way you would allready have the thoughest part of the xml data, being the definition of the elements and attributes.

In your application or script or whatever, you can now program against the Dom to create the first part (or just load it if it is default) and just add nodes for the different records.

Hope you can make anything out of this!

Jordi Reineman
 
Using Visual Basic:

Set rst = New ADODB.Recordset


rst.Open "C:\my documents\myxml.xml", GetConn(CurrentDb.Name), _
adOpenStatic, adLockOptimistic, adCmdFile

Steve King Growth follows a healthy professional curiosity
 
kloner:

Here is an example for a "not so large" xml file to pass thru ADO via HTML/ASP for a pure data stream(no XSLT).


<%@ language=vbscript %>

<html>
<head>
<title></title>
<%
Dim i
dim oRs
dim sTable

set oRs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
set oRs.ActiveConnection = nothing

oRs.CursorLocation = adUseClient
oRs.CursorType = adOpenStatic
oRs.LockType = adLockReadOnly
oRs.Source = YOUR XML FILE
oRs.Open
%>

</head>
<body>

what your text is

<%
sTable = &quot;<table border=1>&quot;
sTable = sTable & &quot;<tr>&quot;

For i = 0 to oRs.Fields.Count - 1
sTable = sTable & &quot;<td><b>&quot; & oRs.Fields(i).Name & &quot;</b></td>&quot;
Next

oRs.MoveNext
sTable. = sTable & &quot;</tr>&quot;
Do while not oRs.EOF
sTable = sTable & &quot;<tr>&quot;
For i = 0 to oRs.Fields.Count - 1
sTable = sTable & &quot;<td><b>&quot; & oRs.Fields(i).Name & &quot;</b></td>&quot;
Next
oRs.MoveNext
sTable. = sTable & &quot;</tr>&quot;
Loop

sTable = sTable & &quot;</table>&quot;
Response.Write sTable
%>
</body>
</html>
<%
oRs.Close
set oRs = nothing
%>


Fear is the mind killer!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top