Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using adPersistXML with ASP and XML

Status
Not open for further replies.

Tamr

MIS
Jun 21, 2001
1
GB
I'm trying save a ADO recordset to an XML object using the adPersistXML option.

The following is the code I am using :

Response.ContentType = "text/xml"

Dim rsCatalogue
Dim xmlDOM

Call openConnection(DataConn) 'Creates connection to db
Set xmlDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")

set rsCatalogue = Server.CreateObject("ADODB.Recordset")
strConn = Application("dbConnect")

Response.Write &quot;<?xml version=&quot;&quot;1.0&quot;&quot; encoding=&quot;&quot;ISO-8859-1&quot;&quot;?>&quot; & vbCRLF

rsCatalogue.Open &quot;sql statement&quot;, strConn

rsCatalogue.Save xmlDOM,adPersistXML

rsCatalogue.Close
Set rsCatalogue=nothing


When I call this from a browser I get the following error:

The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


XML document must have a top level element.


I checked out loads of examples, and they all seem to follow the same format. I know the ADO recordset is returning values, what am I doing wrong ???


 
Hello,
It seems that the error comes from line
rsCatalogue.Save xmlDOM,adPersistXML

In MSDN it says that first parameter of Save methoid should be complete path name of the file where the Recordset is to be saved.
And you are trying to save in xmlDOM which is only object inserver's memory.

Try
rsCatalogue.Save &quot;d:\directory\some.xml&quot;,adPersistXML
and point to directory where web server user(IIS or other) have rights to write from ASP pages.

Hope this helps.
D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top