Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RSS Feed

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I have the following code behind to create an RSS Feed from my database

Code:
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports System.Text
Imports System.Xml
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 objX As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
        objX.WriteStartDocument()
        objX.WriteStartElement("rss")
        objX.WriteAttributeString("version", "2.0")
        objX.WriteStartElement("channel")
        objX.WriteElementString("title", "uberASP.Net NewsWire")
        objX.WriteElementString("link", "[URL unfurl="true"]http://www.uberasp.net/newswire.aspx")[/URL]
        objX.WriteElementString("description", "The latest headlines and articles from the world of ASP.NET, Microsoft() 's Web development platform.")
        objX.WriteElementString("copyright", "(c) 2004, POP World Media, LLC. All rights reserved.")
        objX.WriteElementString("ttl", "5")

        Dim objConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("IslaySQLConnectionString").ConnectionString)
        objConnection.Open()
        Dim sql As String = "SELECT TOP 10 Title, Description, URL, PubDate FROM dbo.tblRss"
        Dim objCommand As New SqlCommand(sql, objConnection)
        Dim objReader As SqlDataReader = objCommand.ExecuteReader()
        While objReader.Read()
            objX.WriteStartElement("item")
            objX.WriteElementString("title", objReader.GetString(0))
            objX.WriteElementString("description", objReader.GetString(1))
            objX.WriteElementString("URL", "[URL unfurl="true"]http://www.uberasp.net/GetArticle.aspx?id="[/URL] + objReader.GetInt32(2).ToString())
            objX.WriteElementString("pubDate", objReader.GetDateTime(3).ToString("R"))
            objX.WriteEndElement()
        End While
        objReader.Close()
        objConnection.Close()

        objX.WriteEndElement()
        objX.WriteEndElement()
        objX.WriteEndDocument()
        objX.Flush()
        objX.Close()
        Response.End()
    End Sub
End Class

However, when i try to view the page i get the error

Code:
XML Parsing Error: no element found
Location: [URL unfurl="true"]http://localhost:50621/Islay/rss.aspx[/URL]
Line Number 1, Column 1:
^

What is causing this?

Thanks
 
Did you trace through your code? Are you getting results back from your SQL statement?
 
I am getting nothing back apart from that error message being displayed. I have copied multiple tutorials online and done exactly the same as mentioned but not luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top