Hi I want to write code that create a rss feed file from database everytime the programe runs. For somereason the below code is not displaying any thing:
**************
rss.aspx.
vb
**************
Imports System.Text
Imports System.Xml
Imports System.Data
Imports System.Data.SqlClient
Partial Class rss
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Response.Clear()
Response.ContentType = "text/xml"
Dim xtw As XmlTextWriter = New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
xtw.WriteStartDocument()
Dim processtext As String = "type=\" & "text/xsl\" & " href=\" & "rss.xsl\"
xtw.WriteProcessingInstruction("xml-stylesheet", processtext)
xtw.WriteStartElement("rss")
xtw.WriteAttributeString("version", "2.0")
xtw.WriteStartElement("channel")
xtw.WriteElementString("title", "Latest Articles List")
xtw.WriteElementString("link", "http://www.yourwebsite.com/")
xtw.WriteElementString("description", "some description here")
Dim sql As String = "Select * from Articles"
Dim constr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db1.mdb"
Dim da As New OleDb.OleDbDataAdapter(sql, constr)
Dim dt As DataTable = New DataTable()
da.Fill(dt)
If dt.Rows.Count > 0 Then
Dim i As Integer
For i = 0 To dt.Rows.Count - 1 Step i + 1
xtw.WriteStartElement("item")
xtw.WriteElementString("title", dt.Rows(i)("Art_Title").ToString())
xtw.WriteElementString("description", dt.Rows(i)("Art_Subject").ToString())
xtw.WriteElementString("link", "http://www.yourwebsite.com/" + dt.Rows(i)("Art_Url").ToString())
xtw.WriteElementString("pubDate", XmlConvert.ToString(Convert.ToDateTime(dt.Rows(i)( "L_Update").ToString())))
xtw.WriteEndElement()
Next
End If
xtw.WriteEndElement()
xtw.WriteEndElement()
xtw.WriteEndDocument()
xtw.Flush()
xtw.Close()
End Sub
End Class
*********
rss.aspx
*********
<%@ Page Language="
VB" AutoEventWireup="true" CodeFile="rss.aspx.
vb" Inherits="rss" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
********
rss.xsl
********
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="/rss/channel/title" />
</title>
</head>
<body>
<table width="75%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td bgcolor="#cccccc">
<xsl:value-of select="/rss/channel/title" />
</td>
</tr>
</table>
<table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="15"></td>
</tr>
<tr>
<td >
This page is the sample syndication feed.
</td>
</tr>
<tr>
<td height="15"></td>
</tr>
<tr>
<td>
You can provide some Description about the RSS Feeds
</td>
</tr>
</table>
<table width="75%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="15"></td>
</tr>
<xsl:for-each select="/rss/channel/item">
<tr>
<td>
<a href="{link}">
<xsl:value-of select="title" />
</a>
</td>
</tr>
<tr>
<td height="5">
<xsl:value-of select="description" />
</td>
</tr>
<tr>
<td height="10">
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>