Solved

asp to vbs rs.save , adPersistXML error

Posted on 2006-07-05
2
614 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

630 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