Solved

asp to vbs rs.save , adPersistXML error

Posted on 2006-07-05
2
611 Views
Last Modified: 2010-05-18
Experts,
here's my question. I have an ASP page that generates some xml files from a recordset using
rs.Save (pagename),adPersistXML
So I have attempted to change the ASP file to a VBS file which, when ran, will generate the XML files. The VBS file runs, but every XML page it creates has this 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.
--------------------------------------------------------------------------------
An invalid character was found in text content. Error processing resource 'file:///V:/MaxVR/xml/vrx_hotelsbycity_properties...
TG!
"

My ASP file creates the XML fine. Any ideas?

Here is my VBS code:

' VBScript source code

strConn="My SQL Conn"

pagename="\\myWEbServer\xml\vrx_hotelsbycity_properties.xml"

sql = "SELECT TOP 100 PERCENT WorldCupGoals, from tblTeams"

' Delete existing file
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(pagename) Then
      objFSO.DeleteFile (pagename)
End IF
Set objFSO = Nothing

' Declare our variables...
Dim conn  ' ADO connection
Dim rs  ' ADO recordset

' We're actually using a connection to our SQL Server:
set conn = createobject("ADODB.connection")
conn.Open strConn

' Execute a query using the connection object.  It automatically
' creates and returns a recordset
Set rs = CreateObject("ADODB.Recordset")
rs.open sql,conn

' Save the file to XML format.
rs.Save (pagename),adPersistXML

' Close our recordset and connection and dispose of the objects
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing

Thanks in advance for any help. I am really stumped and want to get this project of my lap ASAP.

Cheers
0
Comment
Question by:telliot79
2 Comments
 

Author Comment

by:telliot79
ID: 17046949
this works for me now:

strConn="MySQLString"

set conn = CreateObject("ADODB.connection")
set rs = CreateObject("ADODB.recordset")

conn.Open strConn

'populate drop down
sql = "SELECT TOP 100 PERCENT blah blah"

rs.Open sql,conn

Private Function RecordsetToXMLString(oRecordset)
      'convert ado recordset to xml string
      Set oStream = CreateObject("ADODB.Stream")
      oRecordset.save oStream, 1
      sXML = oStream.ReadText
      oStream.Close
      Set oStream = Nothing
      RecordsetToXMLString = sXML
End Function

strXML =  RecordsetToXMLString (rs)

set objXML = CreateObject("MSXML2.DOMDocument")

objXML.LoadXML strXML

objXML.save "D:\test.xml"

rs.Close
set rs=nothing

conn.Close
set conn = nothing


How do I award myself the points?
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 17117901
Closed, 400 points refunded.
Netminder
Site Admin
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Technology Resume 7 66
$q.all is slower or not  in  Angularjs 2 35
What is the optimum percentage to save images for webs. 4 31
Display field if column exists 7 30
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question