generating XML from Access

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default generating XML from Access

    How can I generate xml documents from an access database. Does Access have a feature or is there a serverobject I can use that makes my live easier. Or do I have to code it myself with Vbscript? I just want a simple facility that transforms a table (or a query) into a XML document

    e.g
    Table Persons (firstname,lastname) with data (Herman,Brood) (Bart,Chabott

    should be turned int

    <persons><persons><firstname
    Herma
    </firstname><lastname
    Broo
    </lastname></person><person><firstname
    Bar
    </firstname><lastname
    Chabot
    </lastname></person></persons>
    hoke Guest

  2. Similar Questions and Discussions

    1. Generating PDF from XLS
      Hi, I am trying to generate PDF document from an XLS using Distiller API. In Excel, I have set the page size as A4. However, the generated PDF is...
    2. Reg: Generating WSDL
      Hi, I am trying to generate a WSDL which is compatible with HTNG protocol. Here is the sample wsdl i am interested to generate using ColdFusion MX...
    3. Report Generating
      I have been designing a database using MySQL on my Linux server and using a web based front-end. I have the users entering data into the database...
    4. generating xml from access database
      I am trying to set up an access database and some CF code which will allow for the automatic generation of an .xml for use with RSS. The eventual...
    5. generating GIFs
      I want to write a Perl program that will auto generate GIF images. The images that I want to generate will be about 30x80. It will be a black...
  3. #2

    Default Re: generating XML from Access

    hoke wrote:
    > How can I generate xml documents from an access database. Does Access
    > have a feature
    I don't know. Have you looked in online help? You'll get faster answers for
    your Access questions by asking them on an Access newsgroup
    > or is there a serverobject I can use that makes my
    > live easier. Or do I have to code it myself with Vbscript? I just
    > want a simple facility that transforms a table (or a query) into a
    > XML document.
    I've written my own code to do it. It's pretty trivial. Are you just looking
    for a shortcut or do you have no idea where to start?

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  4. #3

    Default Re: generating XML from Access

    "hoke" <anonymous@discussions.microsoft.com> wrote in message
    news:5C569F05-846A-4437-BECC-EB1CC4CF3976@microsoft.com...
    > How can I generate xml documents from an access database. Does Access have
    a feature or is there a serverobject I can use that makes my live easier. Or
    do I have to code it myself with Vbscript? I just want a simple facility
    that transforms a table (or a query) into a XML document.
    >
    > e.g.
    > Table Persons (firstname,lastname) with data (Herman,Brood) (Bart,Chabott)
    >
    > should be turned into
    >
    > <persons><persons><firstname>
    > Herman
    > </firstname><lastname>
    > Brood
    > </lastname></person><person><firstname>
    > Bart
    > </firstname><lastname>
    > Chabott
    > </lastname></person></persons>

    How about this VBS file.
    It will run standalone for testing.
    It can be converted to an ASP page.
    Watch for word-wrap.

    '*
    '* Read an MS-Access database Catalog and Table to generate an XML file.
    '*
    Option Explicit
    '*
    '* Declare Constants
    '*
    Const cVBS = "Persons.vbs"
    Const cMDB = "Persons.mdb"
    Const cTBL = "Persons"
    '*
    Const adOpenStatic = 3
    '*
    '* Declare Variables
    '*
    Dim strDSN
    strDSN = "DRIVER=Microsoft Access Driver (*.mdb);DBQ="
    Dim intFOR
    Dim strREC
    Dim intREX
    Dim arrRST(99)
    Dim strSQL
    strSQL = "SELECT * FROM " & cTBL
    Dim intTBL
    intTBL = 0
    Dim strXML
    '*
    '* Declare Objects
    '*
    Dim objADO
    Set objADO = CreateObject("ADODB.Connection")
    objADO.Open strDSN & cMDB
    Dim objCAT
    Set objCAT = CreateObject("ADOX.Catalog")
    objCAT.ActiveConnection = strDSN & cMDB
    Dim objCOL
    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Dim objTAB
    Dim objXML
    Set objXML = objFSO.OpenTextFile(cTBL & ".xml",2,true)
    '*
    '* Identify Columns
    '*
    For Each objTAB in objCAT.Tables
    If objTAB.Type = "TABLE" _
    And objTAB.Name = cTBL Then
    For Each objCOL in objTAB.Columns
    intTBL = intTBL + 1
    arrRST(intTBL) = objCOL.Name
    Next
    End If
    Next
    '*
    '* Count Records
    '*
    Dim objRST
    Set objRST = CreateObject("ADODB.Recordset")
    objRST.Open strSQL, strDSN & cMDB, adOpenStatic
    intREX = objRST.RecordCount
    objRST.Close
    Set objRST = Nothing
    '*
    '* Write XML
    '*
    objXML.WriteLine("<?xml version='1.0' ?>" & vbCrLf)
    If intREX = 0 Then
    objXML.WriteLine("<" & cTBL & "_Table>" & vbCrLf)
    objXML.WriteLine(" <" & cTBL & "_Entry>" & vbCrLf)
    For intFOR = 1 To intTBL
    objXML.WriteLine(" <" & arrRST(intFOR) & " />" & vbCrLf)
    Next
    objXML.WriteLine(" </" & cTBL & "_Entry>" & vbCrLf)
    objXML.WriteLine("</" & cTBL & "_Table>" & vbCrLf)
    Else
    Set objRST = objADO.Execute(strSQL)
    objXML.WriteLine("<" & cTBL & "_Table>" & vbCrLf)
    Do While Not objRST.EOF
    objXML.WriteLine(" <" & cTBL & "_Entry>" & vbCrLf)
    For intFOR = 1 To intTBL
    strREC = objRST(arrRST(intFOR))
    If IsNull(strREC) Then strREC = ""
    If strREC = "" Then
    strXML = " />"
    Else
    strXML = ">" & strREC & "</" & arrRST(intFOR) & ">"
    End If
    objXML.WriteLine(" <" & arrRST(intFOR) & strXML & vbCrLf)
    Next
    objXML.WriteLine(" </" & cTBL & "_Entry>" & vbCrLf)
    objRST.MoveNext
    Loop
    objXML.WriteLine("</" & cTBL & "_Table>" & vbCrLf)
    Set objRST = Nothing
    End If
    '*
    '* Destroy Objects
    '*
    Set objADO = Nothing
    Set objCAT = Nothing
    Set objFSO = Nothing
    Set objXML = Nothing
    '*
    '* Finish Message
    '*
    MsgBox "'" & cTBL & ".xml' contains " & intREX & "
    records",vbInformation,cVBS


    McKirahan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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