Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    6

    DB Access e file xml (RSS)

    Salve a tutti, sono un neofita e avrei bisogno di aiuto, ora mi spiego,

    nel mio sito ho una sezione dove vengono inserite e lette le news utilizzando un db access che vorrei esportare sul file rss.xml con i dati del db cosa che in parte sono riuscito a fare con una pagina asp ma solo visualizza sul browser e gli rss me li sono dovuti scrivere a mano.

    Come posso fare questo automaticamente avendo a disposizione un db access?

  2. #2
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    6
    Chi fa da sè far per 3.

  3. #3
    Pure io vorrei tanto sapere come si fa. Ma forse in questo forum ci sono pochi esperti nel campo.
    www.stefanoraone.com Webdesigner Freelance
    www.santamariadileuca.it - Portale turistico informativo, Santa Maria di Leuca

  4. #4
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    6
    Originariamente inviato da sraone77
    Pure io vorrei tanto sapere come si fa. Ma forse in questo forum ci sono pochi esperti nel campo.
    Io ho risolto adattando e modificando una pagina asp (copia/incolla) utilizzando i CDATA per l'importazione dei dati del DB accenti vari compresi.

  5. #5
    Più o meno sono riuscito a fare anche io qualcosa di simile. Ma vorrei che il codice generi una pagina xml.
    www.stefanoraone.com Webdesigner Freelance
    www.santamariadileuca.it - Portale turistico informativo, Santa Maria di Leuca

  6. #6
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    6
    Originariamente inviato da sraone77
    Più o meno sono riuscito a fare anche io qualcosa di simile. Ma vorrei che il codice generi una pagina xml.
    Salva il codice come pagina asp -- esempio createrss.asp
    Ovviamente devi settare con i tuoi dati i altrimenti non funziona,
    ti metto un asterisco alla fine della riga così puoi individuare quali sonole righe da settare. Una volta settato il tutto se tutto è ok vedrai una pagina bianca con il link verso rss.xml nella stessa directory del DB che poi lo farai puntare tramite l' HEAD della tua home per esempio così:
    ----------------------- home.asp o html o .... --------------------------------------------
    <head>
    <link rel="alternate" type="application/rss+xml"
    href="/rss.xml" title="RSS feed Umpire's FVG "> ' directory dove è salvato rss.xml
    </head>
    ----------------------- createxml.asp -----------------------------------------------------
    <html>
    <title>Creazione RSS feed XML da Dbase Access</title>
    <body bgcolor="#FFFFFF">
    <%

    accessdb="nome_del_database" ' senza estensione es. mydb e non mydb.mdb *
    cn="DRIVER={Microsoft Access Driver (*.mdb)};"
    cn=cn & "DBQ=" & server.mappath(accessdb)

    ' Create a server recordset object
    Set rs = Server.CreateObject("ADODB.Recordset")

    nometabella="tuo_nome_tabella" ' inserisci qui il nome della tabella da vedere *

    ' Query the states table from the state_info db
    sql = "select * from "&nometabella&" ORDER BY ID DESC" ' QUERY SQL CHE MI IMPORTA IL CONTENUTO E FA UN SORT DECRESCENTE *

    ' Execute the sql
    rs.Open sql, cn

    ' Move to the first record
    rs.MoveFirst

    ' Nome del file XML che verrà creato
    file_being_created= "rss.xml" ' CREA IL FILE RSS.XML *

    ' create a file system object
    set fso = createobject("scripting.filesystemobject")

    ' create the text file - true will overwrite any previous files
    ' Writes the db output to a .xml file in the same directory
    Set act = fso.CreateTextFile(server.mappath(file_being_creat ed), true)

    ' All non repetitive xml on top goes here
    act.WriteLine("<?xml version=""1.0"" encoding=""iso-8859-1""?>")'SCRIVE NEL FILE XML
    act.WriteLine("<rss version=""2.0"">") 'SCRIVE NEL FILE XML
    act.WriteLine("<channel>")'SCRIVE NEL FILE XML
    act.WriteLine("<title>IL TUO TITOLO</title>")'SCRIVE NEL FILE XML *
    act.WriteLine("<link> TUOLINK_News.asp </link>")'SCRIVE NEL FILE XML *
    act.WriteLine("<language>it</language>")'SCRIVE NEL FILE XML
    act.WriteLine("<description> Notizie via RSS Feed </description>")'SCRIVE NEL FILE XML *

    'Loop to output all the query results to the xml document
    do while not rs.eof


    act.WriteLine("<item>")
    act.WriteLine("<pubDate>" & rs("DATA") & "</pubDate>" )'RECORD DELLA DATA DELLA NEWS SCRIVE NEL FILE XML *
    act.WriteLine("<title>" & rs("TITOLO") & "</title>" ) ' RECORD DEL TITOLO *
    act.WriteLine("<link><![CDATA[http://www.tuosito.it/news?=]]>"& rs("ID")&"</link>") ' CREAZIONE LINK PER OGNI NOTIZIA *
    act.WriteLine("<description>" & rs("ARTICOLO") & "</description>") 'RECORD CHE LEGGE IL CONTENUTO DELLA NEWS *
    act.WriteLine("</item>")

    ' move to the next record
    rs.movenext
    loop

    ' All non repetitive xml on bottom goes here
    act.WriteLine("</channel>")
    act.WriteLine("</rss>")

    ' close the object (xml)
    act.close


    ' Writes a link to the newly created xml document in the browser
    response.write "Rss feed (.xml) è stato creato clicca per vederlo
    " 'SE TUTTO OK CREA UN LINK SUL FILE XML APPENA CREATO
    response.write "on " & now() & "
    "
    %>
    </body>
    </html>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.