Solved

asp to vbs rs.save , adPersistXML error

Posted on 2006-07-05
2
605 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL to update characters in table column 6 126
Does video get better conversion rates? 2 47
Excel Hyperlink Question 4 48
One field not displaying content (ASP Classic) 8 25
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

776 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