I have the following code behind to create an RSS Feed from my database
However, when i try to view the page i get the error
What is causing this?
Thanks
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