RE: Creaet XML file from recordset

From: StephenMcC (StephenMcC_at_discussions.microsoft.com)
Date: 11/23/04


Date: Tue, 23 Nov 2004 06:45:02 -0800

Hi Shachar,

There are a number of ways to do this, one idea may be to iterate thru the
RecordSet creating the xml file from the returned field names and values, ie:

....
....

Dim sXML as string
sXML = "<Records>"

....
'Create and Open ur RecSet
....

Do While Not oRS.EOF
    sXML = sXML & "<Record>"

    Do While i < rs.Fields.Count
          sXML = sXML & "<" & rs.Fields(i).Name & ">" & _
                                rs.Fields(i).Value & _
                                "</" & rs.Fields(i).Name & ">"

         'U could alos reference fields thru their index/name and
         'provide ur own custom tage names containing the values.
    Loop

    sXML = sXML & "</Record>"
Loop

sXML = sXML & "<Records>"

....
close ur RecSet and release objects etc
....

The codes a bit rough and ready but it should get u going. Another idea may
be to create vb objects which are populated from the recordset, then do a
serialise on private members with the obj to generate the xml.

You can get more info on ADO and RecordSets below:

http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscmicrosoftadoprogrammersreference.asp?frame=true

http://msdn.microsoft.com/library/en-us/dnado/html/workshp2.asp?frame=true#workshp2_topic4

http://msdn.microsoft.com/library/en-us/adosql/adoprg02_9cfn.asp?frame=true

Stephen.

"shachar" wrote:

> hi all.
> i'm new with xml, and i want to create an xml file from
> my recordset object.
> BUT i dont want to use the "save" method with
> adPersistXML because i must control the data, so i can
> manipulate it.
> i'm looking for a simple starter example of how to do it
> (mabe with MsXml object?)
> thanks - shachar.
>
>



Relevant Pages

  • Re: how to process data when internet connection broken?
    ... recordset, persist it to an XML file, then open the XML file locally as a ... recordset and manipulate the data as required. ... > So, looks that Microsoft Message Queing can solve this problem, am I ... >>> DataSet) and update the SQL server and local data with the difference. ...
    (microsoft.public.dotnet.faqs)
  • Ordering Columns in Drillthrough
    ... I have a XML file ... >drillthru with the ordering. ... >my own recordset from the recordset created when you do ... >>other information pertaining to an order, ...
    (microsoft.public.sqlserver.olap)
  • Re: Error with reponse.write
    ... I can't help without knowing what's in the recordset. ... an xml file and post the contents of the xml file in your reply to this ... >> a quicker response by posting to the newsgroup. ...
    (microsoft.public.inetserver.asp.general)
  • Load XMLDMO into recordset for PJGrid.ocx
    ... It can be bound to a ADO recordset. ... want to load a Project XML file into the recordset and then bind the grid to ... Here's a snippet that loads the xml file into a DOMDocument ... then how do I get a Project xml file into a recordset? ...
    (microsoft.public.project.vba)
  • to show a recordset as table
    ... Set recSet = New ADODB.Recordset ... .CursorType = adOpenKeyset ... After this code I correctly bind the recordset to the form, ...
    (comp.databases.ms-access)