Hi pgtips,
After reviewing that article again, and some thought, this is what I decided to do.
I created a DTS package in SQL Server that contains an ActiveX Script to pull the data from the DB table and export it into an XML file. I'll eventually schedule this package to run every 10 minutes. I think that this idea works best for me, because users will then access XML data without the DB being queried on each user's visit to the page. So it will end up being more efficient and more secure.
Well, this idea worked with sucess this morning, and there's the ActiveX Script that I'm using:
Code:
'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()
Dim objADORS
Dim objXMLDoc
Dim nodeRoot
Dim nodeTemp
Dim nodeSample
'Create ADO and MSXML DOMDocument Objects
Set objADORS = CreateObject("ADODB.Recordset")
Set objXMLDoc = CreateObject("MSXML2.DOMDocument.4.0")
'Run the stored procedure and load the Recordset
objADORS.Open "SELECT * FROM tblSample", _
"PROVIDER=SQLOLEDB.1;SERVER=SERVERNAME;UID=USERNAME;PWD=PASSWORD;DATABASE=DBNAME;"
'Prepare the XML Document
objXMLDoc.loadXML "<root />"
Set nodeRoot = objXMLDoc.documentElement
'For each record in the Recordset
While Not objADORS.EOF
Set nodeSample = objXMLDoc.createElement("sample")
nodeRoot.appendChild nodeSample
Set nodeTemp = objXMLDoc.createElement("id")
nodeTemp.nodeTypedValue = Trim(objADORS.Fields("id").Value)
nodeSample.appendChild nodeTemp
Set nodeTemp = objXMLDoc.createElement("fname")
nodeTemp.nodeTypedValue = Trim(objADORS.Fields("fname").Value)
nodeSample.appendChild nodeTemp
Set nodeTemp = objXMLDoc.createElement("lname")
nodeTemp.nodeTypedValue = Trim(objADORS.Fields("lname").Value)
nodeSample.appendChild nodeTemp
objADORS.moveNext
Wend
objADORS.Close
Set objADORS = Nothing
'Save the created XML document
objXMLDoc.Save "B:\sample.xml"
Main = DTSTaskExecResult_Success
End Function
And this is the XML output:
<root><sample><id>1</id><fname>Jane</fname><lname>Doe</lname></sample><sample><id>2</id><fname>Joe</fname><lname>Schmo</lname></sample><sample><id>3</id><fname>John</fname><lname>Doe</lname></sample></root>
As you can see, the last step will be to add code to format the code with a tabbed format, like this:
<root>
<sample>
<id>1</id>
<fname>Jane</fname>
<lname>Doe</lname>
</sample>
<sample>
<id>2</id>
<fname>Joe</fname>
<lname>Schmo</lname>
</sample>
<sample>
<id>3</id>
<fname>John</fname>
<lname>Doe</lname>
</sample>
</root>
I'll keep looking into it, but if you know of how to do this, I'd love to know. Thanks for all of your help on this subject...it's greatly appreciated.
KWilliams