OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

XML with ASP as RSS

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> XML with ASP as RSS
Page: [1]
 
yaronbb

 

Posts: 44
Joined: 10/5/2006
Status: offline

 
XML with ASP as RSS - 8/28/2008 15:21:29   
Hi to all,
I have trying to add a RSS page (XML) to a web site with connection to the DB(Access), this is my code below, I get an error MSG “

A name was started with an invalid character.
Line: 1 Character: 2

<% response.contentType = "text/xml" %>


thanks

<% response.contentType = "text/xml" %>
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
    
    <channel>
        <title>title</title>
        <description>description</description>
        <link>link</link>
    
        <%
   	Dim oConn, oRS, strSQL

   	Set oConn = Server.CreateObject("ADODB.Connection")
   	Set oRS = Server.CreateObject("ADODB.Recordset")

   	oConn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("fpdb/Contact.mdb")
   
   	strSQL="SELECT * FROM IcaCar"

	oRS.Open strSQL, oConn, 2, 3
	Do While Not oRS.EOF
            Dim xmlString

            oRecordSet.Open sSQLString,oConnectionObject

            While Not oRecordSet.Eof
                        xmlString = xmlString & "<item>" &_
                                                "<title><![CDATA[" & oRecordSet.Fields("title") & "]]></title>" &_
                                                "<description><![CDATA[" & oRecordSet.Fields("description") & "]]></description>" &_
                                                "<link>" & Server.URLEncode(oRecordSet.Fields("link")) & "</link>" &_
                                                "<pubDate>" & oRecordSet.Fields("date") & "</pubDate>" &_
                                                "</item>"
                        oRecordSet.MoveNext
            Wend
            oRecordSet.Close
            response.write xmlString
        %></channel></rss>

rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: XML with ASP as RSS - 8/28/2008 17:00:00   
quote:

<% response.contentType = "text/xml" %>


If you're just trying to create an XML file, get rid of that line. You don't need that to create an XML file.

If you're trying to turn this into a 'downloadable' XML file that someone clicks on, build all your XML statements into a string variable, and then do something like :


<% 'build your XML string here
call Response.AddHeader("Content-Disposition", "attachment;filename=myrss.xml")
Response.ContentType = "application/download"
Response.write myXMLStringVariable
%>

Something to that effect. In your scenario, try just removing it perhaps.


_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to yaronbb)
TexasWebDevelopers

 

Posts: 722
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: XML with ASP as RSS - 8/28/2008 17:34:15   
We've written a bit of code that takes the title, date, and text from newly created blog entry and generates a new rss.xml file on the fly (pulling other blog entries from a database) using the file scripting object. You don't need anything this complicated but I thought the code might help you walk through the process if you want to do something like this yourself.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% Response.Buffer = False %>
<!--#include file="database_connection.asp" -->
<%
Dim rsConfig
Dim rsConfig_numRows
Set rsConfig = Server.CreateObject("ADODB.Recordset")
rsConfig.ActiveConnection = MM_blog_STRING
rsConfig.Source = "SELECT * FROM BlogRSStable"
rsConfig.CursorType = 0
rsConfig.CursorLocation = 2
rsConfig.LockType = 1
rsConfig.Open()
rsConfig_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>Update RSS</title>
</head>
<body>
<%
Dim artRec
Dim artRec_numRows
Set artRec = Server.CreateObject("ADODB.Recordset")
artRec.ActiveConnection = MM_blog_STRING
artRec.Source = "SELECT * FROM BlogRSStable, tableCat, tableAuthor  WHERE BlogCat = CatID  AND tableBlog.BlogAuthor = tableAuthor.fldAuthorID AND tableBlog.BlogDraft <> 1 ORDER BY BlogDate DESC"
artRec.CursorType = 0
artRec.CursorLocation = 2
artRec.LockType = 1
artRec.Open()
artRec_numRows = 0

sFilename = "D:\Inetpub\wwwroot\read-write-folder\rss.xml"

	Dim objFSO
	Dim fsoFile
	' create an instance of the FileSystemObject
	Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
	' create file
	Set fsoFile = objFSO.CreateTextFile ((sFilename))

Dim objRS__currentDate
objRS__currentDate = "Month(Date())"
If (Month(Date()) <> "") Then 
  objRS__currentDate = Month(Date())
End If

Dim rsBlogConfig
Dim rsBlogConfig_numRows
Set rsBlogConfig = Server.CreateObject("ADODB.Recordset")
rsBlogConfig.ActiveConnection = MM_blog_STRING
rsBlogConfig.Source = "SELECT * FROM tblBlogRSS"
rsBlogConfig.CursorType = 0
rsBlogConfig.CursorLocation = 2
rsBlogConfig.LockType = 1
rsBlogConfig.Open()
rsBlogConfig_numRows = 0

function Do_StripHTML(strtext)				
 on error resume next	
	'Strips the HTML tags from strHTML
	
	Dim objRegExp, strOutput
	Set objRegExp = New Regexp
	
	objRegExp.IgnoreCase = True
	objRegExp.Global = True
	objRegExp.Pattern = "<(.|\n)+?>"
	
	'Replace all HTML tag matches with the empty string
	strOutput = objRegExp.Replace(strtext, "")

	Set objRegExp = Nothing	
	
strOutput = replace(strOutput,""",""") 
strOutput = replace(strOutput,"'","'") 
strOutput = replace(strOutput,"&","&") 
strOutput = replace(strOutput,"<","<") 
strOutput = replace(strOutput,">",">")
strOutput = replace(strOutput," ","  ")                
strOutput = replace(strOutput,"–","–") 
strOutput = replace(strOutput,"—","—") 
strOutput = replace(strOutput,"‘","‘") 
strOutput = replace(strOutput,"’","’")
strOutput = replace(strOutput,"‚","‚")
strOutput = replace(strOutput,"“","“") 
strOutput = replace(strOutput,"”","”") 
strOutput = replace(strOutput,"„","„") 
strOutput = replace(strOutput,"†","†") 
strOutput = replace(strOutput,"‡","‡") 
strOutput = replace(strOutput,"…","…") 
strOutput = replace(strOutput,"¡","¡") 
strOutput = replace(strOutput,"¤","¤") 
strOutput = replace(strOutput,"¢","¢") 
strOutput = replace(strOutput,"£","£") 
strOutput = replace(strOutput,"¥","¥") 
strOutput = replace(strOutput,"¦","¦") 
strOutput = replace(strOutput,"§","§") 
strOutput = replace(strOutput,"¨","¨") 
strOutput = replace(strOutput,"©","©") 
strOutput = replace(strOutput,"ª","ª") 
strOutput = replace(strOutput,"«","«") 
strOutput = replace(strOutput,"¬","¬") 
strOutput = replace(strOutput,"­","­") 
strOutput = replace(strOutput,"®","®") 
strOutput = replace(strOutput,"™","™") 
strOutput = replace(strOutput,"¯","¯") 
strOutput = replace(strOutput,"°","°") 
strOutput = replace(strOutput,"±","±") 
strOutput = replace(strOutput,"²","²") 
strOutput = replace(strOutput,"³","³") 
strOutput = replace(strOutput,"´","´") 
strOutput = replace(strOutput,"µ","µ") 
strOutput = replace(strOutput,"¶","¶") 
strOutput = replace(strOutput,"·","·") 
strOutput = replace(strOutput,"¸","¸") 
strOutput = replace(strOutput,"¹","¹") 
strOutput = replace(strOutput,"º","º") 
strOutput = replace(strOutput,"»","»") 
strOutput = replace(strOutput,"¼","¼") 
strOutput = replace(strOutput,"½","½") 
strOutput = replace(strOutput,"¾","¾") 
strOutput = replace(strOutput,"¿","¿") 
strOutput = replace(strOutput,"×","×") 
strOutput = replace(strOutput,"÷","÷") 
strOutput = replace(strOutput,"À","À") 
strOutput = replace(strOutput,"Á","Á") 
strOutput = replace(strOutput,"Â","Â") 
strOutput = replace(strOutput,"Ã","Ã") 
strOutput = replace(strOutput,"Ä","Ä") 
strOutput = replace(strOutput,"Å","Å") 
strOutput = replace(strOutput,"Æ","Æ") 
strOutput = replace(strOutput,"Ç","Ç") 
strOutput = replace(strOutput,"È","È") 
strOutput = replace(strOutput,"É","É") 
strOutput = replace(strOutput,"Ê","Ê") 
strOutput = replace(strOutput,"Ë","Ë") 
strOutput = replace(strOutput,"Ì","Ì") 
strOutput = replace(strOutput,"Í","Í") 
strOutput = replace(strOutput,"Î","Î") 
strOutput = replace(strOutput,"Ï","Ï") 
strOutput = replace(strOutput,"Ð","Ð") 
strOutput = replace(strOutput,"Ñ","Ñ") 
strOutput = replace(strOutput,"Ò","Ò") 
strOutput = replace(strOutput,"Ó","Ó") 
strOutput = replace(strOutput,"Ô","Ô") 
strOutput = replace(strOutput,"Õ","Õ") 
strOutput = replace(strOutput,"Ö","Ö") 
strOutput = replace(strOutput,"Ø","Ø") 
strOutput = replace(strOutput,"Ù","Ù") 
strOutput = replace(strOutput,"Ú","Ú") 
strOutput = replace(strOutput,"Û","Û") 
strOutput = replace(strOutput,"Ü","Ü") 
strOutput = replace(strOutput,"Ý","Ý") 
strOutput = replace(strOutput,"Þ","Þ") 
strOutput = replace(strOutput,"ß","ß") 
strOutput = replace(strOutput,"à","à") 
strOutput = replace(strOutput,"á","á") 
strOutput = replace(strOutput,"â","â") 
strOutput = replace(strOutput,"ã","ã") 
strOutput = replace(strOutput,"ä","ä") 
strOutput = replace(strOutput,"å","å") 
strOutput = replace(strOutput,"æ","æ") 
strOutput = replace(strOutput,"ç","ç") 
strOutput = replace(strOutput,"è","è") 
strOutput = replace(strOutput,"é","é") 
strOutput = replace(strOutput,"ê","ê") 
strOutput = replace(strOutput,"ë","ë") 
strOutput = replace(strOutput,"ì","ì") 
strOutput = replace(strOutput,"í","í") 
strOutput = replace(strOutput,"î","î") 
strOutput = replace(strOutput,"ï","ï") 
strOutput = replace(strOutput,"ð","ð") 
strOutput = replace(strOutput,"ñ","ñ") 
strOutput = replace(strOutput,"ò","ò") 
strOutput = replace(strOutput,"ó","ó") 
strOutput = replace(strOutput,"ô","ô") 
strOutput = replace(strOutput,"õ","õ") 
strOutput = replace(strOutput,"ö","ö") 
strOutput = replace(strOutput,"ø","ø") 
strOutput = replace(strOutput,"ù","ù") 
strOutput = replace(strOutput,"ú","ú") 
strOutput = replace(strOutput,"û","û") 
strOutput = replace(strOutput,"ü","ü") 
strOutput = replace(strOutput,"ý","ý") 
strOutput = replace(strOutput,"þ","þ") 
strOutput = replace(strOutput,"ÿ","ÿ") 
strOutput = replace(strOutput,"Œ","Œ") 
strOutput = replace(strOutput,"œ","œ") 
strOutput = replace(strOutput,"Š","Š") 
strOutput = replace(strOutput,"š","š") 
strOutput = replace(strOutput,"Ÿ","Ÿ") 
strOutput = replace(strOutput,"ˆ","ˆ") 
strOutput = replace(strOutput,"˜","˜") 
strOutput = replace(strOutput," "," ") 
strOutput = replace(strOutput," "," ") 
strOutput = replace(strOutput," "," ") 
strOutput = replace(strOutput,"‌","‌") 
strOutput = replace(strOutput,"‍","‍") 
strOutput = replace(strOutput,"‎","‎") 
strOutput = replace(strOutput,"‏","‏") 
strOutput = replace(strOutput,"‰","‰") 
strOutput = replace(strOutput,"‹","‹") 
strOutput = replace(strOutput,"›","›") 
strOutput = replace(strOutput,"€","€") 
strOutput = replace(strOutput,Chr(10),"")
strOutput = replace(strOutput,Chr(13),"")
strOutput = replace(strOutput,"&","&")
strOutput = replace(strOutput,"'","'")
strOutput = replace(strOutput,"§","§")
strOutput = replace(strOutput,"©","©")
strOutput = replace(strOutput,"®","®")
strOutput = replace(strOutput,"¦","¦")

  Do_StripHTML = strOutput	
End Function														

Function return_RFC822_Date(myDate, offset)
  Dim myDay, myDays, myMonth, myYear
  Dim myHours, myMonths, mySeconds
	
  myDate = CDate(myDate)
  myDay = WeekdayName(Weekday(myDate),true)
  myDays = Day(myDate)
  myMonth = MonthName(Month(myDate), true)
  myYear = Year(myDate)
  myHours = zeroPad(Hour(myDate), 2)
  myMinutes = zeroPad(Minute(myDate), 2)
  mySeconds = zeroPad(Second(myDate), 2)
	
  return_RFC822_Date = myDay&", "& _
                       myDays&" "& _
                       myMonth&" "& _ 
                       myYear&" "& _
                       myHours&":"& _
                       myMinutes&":"& _
                       mySeconds&" "& _ 
                       offset
End Function 
Function zeroPad(m, t)
  zeroPad = String(t-Len(m),"0")&m
End Function

	twdSiteTitle = (rsBlogConfig.Fields.Item("blogTitle").Value)
	twdSiteDescr = (rsBlogConfig.Fields.Item("blogDesc").Value)
	twdSiteURL = (rsBlogConfig.Fields.Item("blogURL").Value)
	if right(twdSiteURL, 1) <> "/" then
		twdSiteURL = sSiteURL & "/"
	end if
	twdSiteDetails = ""
	twdImageURL = (rsBlogConfig.Fields.Item("blogImage").Value)
	twdFurtherReading = ""
	twdAuthorNames = (rsBlogConfig.Fields.Item("blogAuthor").Value)
	twdAuthorEmails = (rsBlogConfig.Fields.Item("blogEmail").Value)


fsoFile.WriteLine ("<?xml version=""1.0""?>")
'fsoFile.WriteLine ("<?xml-stylesheet type=""text/css"" href=""" & sSiteURL &  "rss.css"" ?>")
fsoFile.WriteLine ("<!--  RSS generated by " & twdSiteTitle & " on " & Now() & " -->")
fsoFile.WriteLine ("<rss version=""2.0""  xmlns:atom=""http://www.w3.org/2005/Atom"">")
fsoFile.WriteLine ("<channel>")
fsoFile.WriteLine("<title>Blog Title</title>")
fsoFile.WriteLine("<atom:link href=""http://yourwebsite/read-write-folder/rss.xml"" rel=""self"" type=""application/rss+xml"" />")
fsoFile.WriteLine("<link>" & twdSiteURL & "</link>")
fsoFile.WriteLine("<description>Blog RSS feed</description>")
fsoFile.WriteLine("<language>en-us</language>")
fsoFile.WriteLine("<pubDate>Mon, 28 Jul 2008 09:00:00 GMT</pubDate>")
fsoFile.WriteLine("<lastBuildDate>" & return_RFC822_Date(Now(), "GMT") & "</lastBuildDate>")
fsoFile.WriteLine("<webMaster>yourname@yoursite.com</webMaster>")

Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
artRec_numRows = artRec_numRows + Repeat1__numRows

While ((Repeat1__numRows <> 0) AND (NOT artRec.EOF)) 

	fsoFile.WriteLine ("<item>")
	fsoFile.WriteLine ("<title>" & (CropSentence(Do_StripHTML(artRec.Fields.Item("BlogHeadline").Value), 500, "...")) & "</title>")
	fsoFile.WriteLine ("<link>" & sSiteURL & "permalink.asp?id=" & artRec.Fields.Item("BlogID").Value & "</link>")
	fsoFile.WriteLine ("<guid isPermaLink=""true"">" & sSiteURL & "permalink.asp?id=" & artRec.Fields.Item("BlogID").Value & "</guid>")
	fsoFile.WriteLine ("<description>" & (CropSentence(Do_StripHTML(artRec.Fields.Item("BlogHTML").Value), 250, "...")) & "</description>")
	fsoFile.WriteLine ("<pubDate>" & return_RFC822_Date(artRec.Fields.Item("BlogDate").Value, "GMT") & "</pubDate>")
	fsoFile.WriteLine("<category domain=""" & twdSiteURL & "archives_cat.asp?cat=" & artRec.Fields.Item("CatID").Value & """>" & artRec.Fields.Item("CatName").Value & "</category>")
	fsoFile.WriteLine ("</item>")

  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  artRec.MoveNext()
Wend

' Write out the End Channel Data tag and End RSS tag.
fsoFile.WriteLine ("</channel>")
fsoFile.WriteLine ("</rss>")
	fsoFile.Close 
	Set fsoFile = Nothing
	Set objFSO = Nothing

rsBlogConfig.Close()
Set rsBlogConfig = Nothing

artRec.Close()
Set artRec = Nothing
%>
</body>
</html>
<%
rsConfig.Close()
Set rsConfig = Nothing
%>


(in reply to rdouglass)
yaronbb

 

Posts: 44
Joined: 10/5/2006
Status: offline

 
RE: XML with ASP as RSS - 8/28/2008 20:58:19   
Hi, thanks for the response…

I need a simple code just to make a RSS feeds with my asp.

I did remove the “<% response.contentType = "text/xml" %>” but now I get this error MSG “Microsoft VBScript compilation error '800a03fb'
Expected 'Loop'
/test/test.asp, line 36


thanks

(in reply to TexasWebDevelopers)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: XML with ASP as RSS - 8/28/2008 22:42:10   
quote:

While Not oRecordSet.Eof


Try changing that to:

Do While Not oRecordSet.Eof

and change the "Wend" to "Loop"

That any better?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to yaronbb)
yaronbb

 

Posts: 44
Joined: 10/5/2006
Status: offline

 
RE: XML with ASP as RSS - 8/29/2008 9:46:48   
Hi, thanks for the help I found how to make a simple RSS connection with asp page here is the code.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-
0.91.dtd">
<rss version="0.91">
   <channel>

      <title>test</title>
      <link>test</link>
      <description>test</description>
      <language>EN</language>

   <image>
      <title>test</title>
      <url>test</url>
      <link>test</link>
   </image>
<%
   Set Conn = Server.CreateObject("ADODB.Connection")
   Conn.Open  "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("fpdb/Contact.mdb")
   Set Rec = Conn.Execute("select * from IceCar")

   x=0

   while not Rec.eof
   
   if x<6 then

   response.write "<item>"
   response.write "<title>"& Rec("AAbout") &"</title>"
   response.write "<link>http://www.test.com/1.asp?1="& Rec("ID") &"</link>"
   response.write "<description>"& Rec("AAbout")&"</description>"
   response.write "</item>"

   end if

   x=x+1

   Rec.movenext
   wend

   set Rec = nothing
   Conn.close
   set Conn = nothing
%></channel></rss>



Thanks

(in reply to rdouglass)
Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> XML with ASP as RSS
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts