Solved

asp to vbs rs.save , adPersistXML error

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn how to count occurrences of each item in an array.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now