Results 1 to 4 of 4

Thread: [RESOLVED] VB6 and XML pls help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2011
    Posts
    23

    Resolved [RESOLVED] VB6 and XML pls help

    Hi guys i am trying out to following code
    to export recordset to XML
    //////////////////////////////////////////////////////////////////
    Code:
    Private Sub cmdMakeXmlFile_Click()
    Dim db_name As String
    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim xml As DOMDocument
    Dim xml2 As DOMDocument
    
        db_name = txtDatabase.Text
    
        Set conn = New ADODB.Connection
        conn.ConnectionString = _
            "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Persist Security Info=False;" & _
            "Data Source=" & db_name
        conn.Open
    
        Set rs = conn.Execute("SELECT * FROM Movies ORDER BY Title")   
    
        Set xml = New DOMDocument
        Set xml2 = New DOMDocument
        xml.async = False 'novo
        xml2.async = False
        rs.Save xml, adPersistXML
    
        rs.Close
        conn.Close
    
        db_name = Replace$(db_name, ".mdb", ".xml")
        xml.Save db_name
        MsgBox "Done"
    ////////////////////////////////////////////////////////////////////
    but i get xml scheme like

    <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
    - <s:Schema id="RowsetSchema">
    - <s:ElementType name="row" content="eltOnly">
    - <s:AttributeType name="Rate" rs:number="1" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
    <s:datatype dt:type="int" dt:maxLength="4" rsrecision="10" rs:fixedlength="true" />
    </s:AttributeType>
    - <s:AttributeType name="RDate" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
    <s:datatype dt:type="dateTime" rs:dbtype="variantdate" dt:maxLength="16" rs:fixedlength="true" />
    </s:AttributeType>
    - <s:AttributeType name="Title" rs:number="3" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
    <s:datatype dt:type="string" dt:maxLength="40" />
    </s:AttributeType>
    <s:extends type="rs:rowbase" />
    </s:ElementType>
    </s:Schema>
    - <rs:data>
    <z:row Rate="2" RDate="2010-05-01T00:00:00" Title="Adam2" />
    <z:row Rate="3" RDate="2010-05-01T00:00:00" Title="Adam3" />
    <z:row Rate="4" RDate="2010-05-01T00:00:00" Title="Adam4" />
    <z:row Rate="1" RDate="2010-05-01T00:00:00" Title="Adm" />
    <z:row Rate="5" RDate="2010-05-01T00:00:00" Title="Eva" />
    </rs:data>
    </xml>
    ////////////////////////////////////////////////////////////////////
    But i need a simple tree like

    <?xml version="1.0" encoding="utf-8" ?>
    - <Movies xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <MovieName>sws</MovieName>
    <MovieRating>2011-07-30T00:00:00+03:00</MovieRating>
    <MovieReleaseDate>223467</MovieReleaseDate>
    </Movies>
    /////////////////////////////////////////////////////////////////////

    Any ideas?!

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: VB6 and XML pls help

    Simple serialization of an ADO Recordset to XML uses special schemas as you have seen.

    To do anything else you have to perform the serialization manually. This is no big deal until you want to use your own (or the stock) schemas. For example nodes of type xsd:dateTime have to be encoded as ISO 8601 date & time strings, and VB6 has no readily available support for doing this (roll your own code).

    I'm not even sure what type this element is supposed to be:

    <MovieReleaseDate>223467</MovieReleaseDate>

    By rights I'd expect xsd:date, but those look like:

    2002-09-24
    2002-09-24Z
    2002-09-24+06:00

    etc.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VB6 and XML pls help

    and if you look at the OP's rating node, it's a date... I think it's a simple swap/mistype ...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: VB6 and XML pls help

    Duhhh! (smacks forehead)

Posting Permissions

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



Click Here to Expand Forum to Full Width