Link to home
Start Free TrialLog in
Avatar of Belazir
Belazir

asked on

Import XML into recordset *NOT PERSIST FORMAT*

I'm looking for some sample code that will allow me to convert an XML file into an ADO recordset.  Excel seems to have functions built in that convert XML straight into a table format in exactly the style I need, but it seems clumsy to have to open the XML file in Excel, save that down and then open that as a recordset - surely there is an easier way?

PLEASE NOTE this XML file was not created using the XML Persist option from the Save method of ADO.  It is just a bog standard XML file:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Devices>
<Device>
<Device_Name />
<LC_Description>LC GBR</LC_Description>
<Site_ID>WLH</Site_ID>
<Device_ID>10005999</Device_ID>
</Device>
<Device>
<Device_Name />
<LC_Description>LC GBR</LC_Description>
<Site_ID>WLH</Site_ID>
<Device_ID>10006005</Device_ID>
</Device>
</Devices>

Can anyone help?

I'll need some sample code to get the points I'm afraid, pointing me in the right direction won't be enough.  A complete answer will get a further 500 points in a separately posted question.
Avatar of arif_eqbal
arif_eqbal

Well it can be done easily if you use ADO 2.5 Library, it allows you to create a ADO recordset from an XML file opened as a straem.

You want sample code, a full blown sample is available visit:

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q263/2/47.ASP&NoWebContent=1

OR

search for string

"How To Obtain an ADO Recordset from XML"

in MSDN
Avatar of Belazir

ASKER

Arif

From MSDN:

"For more information regarding the schema an XML document must conform to to be opened correctly by an ADO 2.5 recordset, see the "XML Persistence Format" section of the following article:
XML Integration Features in ADO 2.5"

As stated, my XML file does not conform so I cannot open it this way.  If this is possible without the format being as described please show me how as I have tried this with no success.
B

Well If this does not work then I think then you will need to parse the xml file using some xml parser and create a disconnected recordset manually.
ASKER CERTIFIED SOLUTION
Avatar of LeighWardle
LeighWardle
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Belazir

ASKER

Thanks Leigh, just what I was after.
B