How to save a recordset as XML without the namespace attributes?

Discussion in 'ASP General' started by ferd, Jan 11, 2006.

  1. ferd

    ferd Guest

    Hello,

    I want to query an access database in ASP (classic) and save the
    results as an XML file that I can use as a Data Island in Internet
    Explorer - I have the recordset, I can save it as XML, but there's a
    bunch of junk at the beginning of the file that makes the IE data
    island mechanism not work.

    here's what I do:
    dim objXML
    Set objXML = Server.CreateObject("MSXML2.DOMDocument")

    'LOAD DATA
    'dim objRS : set objRS = m_Connection.Execute(m_sSQL)

    'TRANSFER DATA FROM RS TO XML
    With rsClass
    Call .Save(objXML, 1) '1 - indicates to save Recordset as XML
    Call .Close()
    End With
    objXML.save( "D:\InetPub\wwwroot\testarea\critiqueformdata.xml")


    the resulting XML starts off with

    <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">

    lotsa attributes followed by <s:Schema ...

    lotsa stuff I either don't need or cause IE not to process it
    correctly.

    However when doing XML data inline in the HTML with Internet Explorer
    it DOES work with a simpler xml file like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <dataroot>
    <CritiqueFormData>
    <ModuleName>My Module</ModuleName>
    <date>30 January</date>
    <Active>0</Active>
    </CritiqueFormData>
    <CritiqueFormData>
    <ModuleName>My Second Module</ModuleName>

    etc...


    any ideas how I can either omit the attirbutes and schema descriptor
    information in the ASP export (or the MS Access export, for that
    matter) ....

    OR

    to get IE to properly loop through this data when I have a table
    declaration like this:

    <table datasrc="#critiqueformdata" width="700px" border="1">
    <tr>
    <td><span id="coursetitle" datasrc="#critiqueformdata"
    datafld="ModuleName"></span></td>


    etc....


    THANKS in advance!

    ferd
     
    ferd, Jan 11, 2006
    #1
    1. Advertising

  2. ferd wrote:
    > Hello,
    >
    > I want to query an access database in ASP (classic) and save the
    > results as an XML file that I can use as a Data Island in Internet
    > Explorer - I have the recordset, I can save it as XML, but there's a
    > bunch of junk at the beginning of the file that makes the IE data
    > island mechanism not work.
    >


    See http://www.davidpenton.com/testsite/tips/xml.data.islands.asp
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jan 11, 2006
    #2
    1. Advertising

  3. ferd

    ferd Guest

    Thanks for the response. I couldn't get the code to work for me,
    probably becase of the first line - the include:

    <!--#include virtual="/testsite/global_include.asp" --> (couldn't find
    that fiile)


    but I think I get the gist of it - write yer own - in order to not have
    the extra attributes or schema information, e.g


    <?xml version="1.0" encoding="UTF-8"?>
    <data>
    <row>
    <field1>blah blah</field1>
    </row>
    </data>

    and not

    <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" rs:updatable="true">

    etc...


    ..... I need to write my own exporter in asp. Seems odd that even in
    MS Word it is possible to choose "Data Only" and export simple, clean
    XML. I was hoping that Access or ASP would have the option to do the
    same. arrgh.

    thanks again
    ferd
     
    ferd, Jan 12, 2006
    #3
  4. ferd wrote:
    > Thanks for the response. I couldn't get the code to work for me,
    > probably becase of the first line - the include:
    >
    > <!--#include virtual="/testsite/global_include.asp" --> (couldn't find
    > that fiile)
    >

    That line was added by the guy who posted this code to his site. The include
    file contains the database connection info and the functions needed to
    display the code on the resulting page sent to the browser.

    You will need to supply your own database connection information to enable
    this code to work on your own server.

    >
    > but I think I get the gist of it - write yer own - in order to not
    > have the extra attributes or schema information, e.g

    <snip>
    >
    > .... I need to write my own exporter in asp. Seems odd that even in
    > MS Word it is possible to choose "Data Only" and export simple, clean
    > XML. I was hoping that Access or ASP would have the option to do the
    > same. arrgh.
    >

    That's the difference between the latest version of an end-user interface
    (Word 2003) and a programming language/development environment that was in
    existence long before xml was even a twinkle in somebody's eye and has not
    been updated in a few years ... :)

    Actually, even ADO.Net has no way to do this without the developer
    overriding the XMLSerializer class. They assume you want to be able to
    deserialize the resulting xml back into the object from which it was
    serialized (this is usually the case).

    If you're using SQL 2000+, you can use a "FOR XML" clause to get close to
    what you want.

    --
    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], Jan 12, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    621
  2. Replies:
    0
    Views:
    431
  3. Kasp
    Replies:
    0
    Views:
    470
  4. Hung Huynh
    Replies:
    8
    Views:
    348
    Bob Barrows
    Sep 24, 2003
  5. Kasp

    ADO Recordset Save as XML error

    Kasp, Nov 15, 2005, in forum: ASP General
    Replies:
    10
    Views:
    425
    Bob Barrows [MVP]
    Nov 16, 2005
Loading...

Share This Page