469,925 Members | 1,519 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,925 developers. It's quick & easy.

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

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

Jan 11 '06 #1
3 2925
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/...ta.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"
Jan 12 '06 #2
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

Jan 12 '06 #3
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.
Jan 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Adrian Parker | last post: by
25 posts views Thread by kj | last post: by
3 posts views Thread by Edward Grosso via .NET 247 | last post: by
6 posts views Thread by Andy Barber | last post: by
5 posts views Thread by C Watson | last post: by
13 posts views Thread by Axel Dahmen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.