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
Solved

asp to vbs rs.save , adPersistXML error

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

860 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