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

F

ferd

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
 
F

ferd

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
 
B

Bob Barrows [MVP]

ferd said:
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
.... 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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top