Codice PHP:
<%
'Stringa di connessione al nostro Data Base di news
'da modificare in base al percorso del vostro Data Base
StrConnessione = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & _
server.MapPath("/rss/ASP") & "\News.mdb"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open StrConnessione
'Istruzione SQL che prende le news dal Data Base;
'da cambiare con il nome della vostra tabella ed i nomi dei campi
SQL = "SELECT * FROM news Order by idnews desc"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = 3
rs.Open SQL, Conn, 1,1
' Numero totale di records
totfiles = rs.recordcount
xml = "<?xml version=""1.0"" encoding=""UTF-8""?>" & _
"<rss version=""2.0""><channel><title>Le Ultime Notizie</title>" & _
"<description>Notizie dal mondo in tempo reale</description>" & _
"<link>[url]http://www.tgcom.it[/url]</link><language>it</language>"
'Se il Record Set non è vuoto
if totfiles <> 0 then
Do while not rs.eof
xml = xml & "<item>"
xml = xml & "<title><![CDATA[" & rs("titolo") & "]]></title>"
xml = xml & "<description><![CDATA[" & rs("descrizione") & "]]></description>"
xml = xml & "<link><![CDATA[[url]http://www.tuosito.com/legginews.asp?id=[/url]" & rs("idnews") & "]]></link></item>"
rs.movenext
Loop
End if
xml = xml & "</channel></rss>"
' Impostazione che setta il tipo di file in output su XML
response.ContentType = "text/xml"
response.write xml
'Libero Risorse
rs.close
set rs=nothing
Conn.Close
set Conn=nothing
%>
Basta adattarlo alle tue esigenze