Click to See Complete Forum and Search --> : rss and asp


jrthor2
10-07-2004, 01:07 PM
I am trying to create a valid rss 2.0 file to syndicate an area of my website. Below is the code I am using. I am not getting any results.


<?xml version="1.0"?>
<% Response.Buffer = true
'Response.ContentType = "text/xml"

Function ApplyXMLFormatting(strInput)
strInput = Replace(strInput,"&", "&amp;")
strInput = Replace(strInput,"'", "&apos;")
strInput = Replace(strInput,"""", "&quot;")
strInput = Replace(strInput, ">", "&gt;")
strInput = Replace(strInput,"<","&lt;")

ApplyXMLFormatting = strInput
End Function
%>

<rss version="2.0">
<channel>
<title>xxx</title>
<link>http://www.xxx.org</link>
<description>List of the xxx</description>
<language>en-us</language>
<copyright></copyright>
<lastBuildDate><%=Now()%></lastBuildDate>
<ttl>20</ttl>
<%
Dim conn
db = "/db/hso.mdb"
today = Month(Date) & "/" & Day(Date) & "/" & Year(Date)
Set conn = server.createobject("adodb.connection")
DSNtemp="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath(db)
conn.Open DSNtemp

Dim objRS, strSQL, strDesc
strSQL = "SELECT id, rehearsal_dte, rehearsal_place, rehearsal_time from Rehearsals where"
strSQL = strSQL & ("rehearsal_dte >= #" & today & "#")
strSQL = strSQL & ("order by rehearsal_dte asc, rehearsal_time asc")
Set objRS = conn.Execute(strSQL)

Do While Not objRS.EOF
strDesc = "<b>Date:</b> " & objRS("REHEARSAL_DTE").Value & "<b>Place:</b> " & _
objRS("REHEARSAL_PLACE").Value
%>

<item>
<title>xxx</title>
<link>http://www.xxx.org</link>
<description><%=ApplyXMLFormatting(strDesc)%></description>
</item>
<%
objRS.MoveNext
Loop

objRS.Close
Set objRS = Nothing

objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>
</channel>
</rss>


I get a blank page and here is the view source:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

jrthor2
10-08-2004, 09:15 AM
Can anyone help here? I found a script that will give me an xml file of my database, but it doesn't format it for rss 2.0. Could someone please help me? here is the code tat gives ma an xml file


Dim conn, objRS, strSQL
db = "/db/ziondb.mdb"
today = Month(Date) & "/" & Day(Date) & "/" & Year(Date)

Set conn = server.createobject("adodb.connection")
DSNtemp="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath(db)
conn.Open DSNtemp

Set objRS = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT * from News where category = 'Front Page' and begin_dte <= #" & today & "# and end_dte >= #" & today & "# order by begin_dte desc"
Set objRS = conn.Execute(strSQL)


'Output the XML
Response.ContentType = "text/xml"
Response.Write(ConvertRStoXML(objRS, "Zion_Lutheran_Church", "News"))

'Clean up
objRS.Close
Set objRS = Nothing


Function ConvertRStoXML(objRS, strTopLevelNodeName, strRowNodeName)
Dim objXMLDom
Dim objXMLRoot
Dim objattTabOrder
Dim objPI
Dim Field

Dim aryRows, intCurRowIdx, intCurFieldIdx, intNumFields, intNumRows
Dim objXMLRow, objXMLField, objXMLFieldName, objXMLFieldValue, objXMLNodeList

'Instantiate the Microsoft XMLDOM.
Set objXMLDom = Server.CreateObject("Microsoft.XMLDOM")
objXMLDom.preserveWhiteSpace = True


'Create the root element and append it to the XML document.
Set objXMLRoot = objXMLDom.createElement(strTopLevelNodeName)
objXMLDom.appendChild objXMLRoot


'Create the Row and Field elements
Set objXMLRow = objXMLDom.CreateElement(strRowNodeName)
Set objXMLField = objXMLDom.createElement("field")


'Build the Field element including its attribute and child
Set objXMLFieldName = objXMLDom.createAttribute("name")
Set objXMLFieldValue = objXMLDom.createElement("value")
objXMLField.SetAttributeNode(objXMLFieldName)
objXMLField.appendChild objXMLFieldValue


'Build the template row by adding all the field names from the Recordset
For Each Field in objRS.Fields
Call objXMLField.SetAttribute("name", Field.Name)
objXMLRow.appendChild objXMLField

'Copy the field to give it a new memory address (copy all its children too)
Set objXMLField = objXMLField.cloneNode(True)
Next

'Convert our Recordset to the multi-dimensional array and calculate its bounds
aryRows = objRS.getRows()

intNumFields = UBound(aryRows)
intNumRows = UBound(aryRows, 2)


'Iterate through the array of data and build the Rows
For intCurRowIdx = 0 To intNumRows
'Retrieve all the Field nodes within the Row
Set objXMLNodeList = objXMLRow.getElementsByTagName("field")

'Add the data for the fields.
'We know there's only one child for each Field (the FieldValue node) so the FirstChild property will work fine
For intCurFieldIdx = 0 To intNumFields
Set objXMLField = objXMLNodeList.item(intCurFieldIdx)
Set objXMLFieldValue = objXMLField.FirstChild
objXMLFieldValue.text = aryRows(intCurFieldIdx, intCurRowIdx)
Next

'Build the populated Row
objXMLRoot.appendChild objXMLRow

'Copy the current row to give it a new memory address (copy children too)
Set objXMLRow = objXMLRow.CloneNode(True)
Next

Set objPI = objXMLDom.createProcessingInstruction("xml", "version='1.0'")
objXMLDom.insertBefore objPI, objXMLDom.childNodes(0)

ConvertRStoXML = objXMLDom.xml

'Clean up...
Set aryRows = Nothing
Set objXMLDom = Nothing
Set objXMLRoot = Nothing
Set objXMLField = Nothing
Set objXMLFieldValue = Nothing
Set objXMLFieldName = Nothing
Set objattTabOrder = Nothing
Set objPI = Nothing
Set conn = Nothing
End Function

jrthor2
10-09-2004, 04:31 PM
can anyone help here?

jrthor2
10-12-2004, 10:55 PM
I got my rss 2.0 scripts to work.