Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400

    Leggere e pubblicare dati di un db mysql tramite ASP e XML

    Ciao.

    Avrei bisogno di leggere e pubblicare dei dati di un db mysql tramite ASP e XML.
    Ho cercato su google ma con scarso successo.

    Sapete indicarmi qualcosa che fa al caso mio ?
    Grazie

  2. #2

  3. #3
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400
    Grazie, l'articolo è molto interessante e vi ho preso spunto.

    Ho creato la pagina default.asp e default-2.asp.

    Ma la pag default-2.asp restituisce sempre "Nessuna news da visualizzare".

    Perchè?

    default.asp
    codice:
    <%
    
    Set objconn = Server.CreateObject("ADODB.Connection")
    objconn.Open "DRIVER={MySQL ODBC 5.1 Driver};SERVER=xxx;DATABASE=xxx;USER=xxx;PASSWORD=xxx;OPTION=3;"
    
    SQL = "SELECT SQL_CALC_FOUND_ROWS id, nome FROM tbl_login WHERE 1 order by id desc LIMIT 1;"
    Set rs = Server.CreateObject("ADODB.RecordSet")
    rs.Open SQL, objconn
    
    If not rs.eof then
    
    SQL = "SELECT FOUND_ROWS() x;"
    Set objRs = objconn.execute(SQL)
    
    xml = "<?xml version=""1.0"" encoding=""UTF-8""?>" & _
          "<rss version=""0.91"">" & _
          "<channel>" & _
          "<title>Le Ultime Notizie</title>" & _
          "<description>Notizie dal mondo in tempo reale</description>" & _
          "<link>http://localhost/xml/default.asp</link>" & _
          "<language>it</language>"
    
      Do while not rs.eof
        xml = xml & "<item>"
        xml = xml & "<title><![CDATA[" & rs("nome") & "]]></title>"    
        xml = xml & "<description><![CDATA[" & objRs("x") & "]]></description>"    
        xml = xml & "</item>"  
        rs.movenext
      Loop
      
      objRs.close
      set objRs=nothing
    
    End if
    
    xml = xml & "</channel></rss>"
    
    response.ContentType = "text/xml"
    response.write xml
    
    rs.close
    set rs=nothing
    
    objconn.Close
    set objconn=nothing
    
    %>

    default-2.asp
    codice:
    <%
    
    url="http://localhost/xml/default.asp"
    
    Set objXML = Server.CreateObject("msxml2.DOMDocument.3.0")
    objXML.async = false
    objXML.setProperty "ServerHTTPRequest", True
    
    objXML.validateOnParse = false 'true
    
    objXML.preserveWhiteSpace = false
    blnLoaded = objXML.Load(url)
    
    If Not blnLoaded Then
      Response.write "Nessuna news da visualizzare"
    Else
      set objNodeList = objXML.getElementsByTagName("channel")
      
      For Each objNode In objNodeList
        For Each objNode2 In objNode.childNodes
      
          Select Case objNode2.nodeName
            Case "title"
              html = html + "<tr><td>"
              html = html + objNode2.firstChild.nodevalue
              html = html + "</td></tr>"
            Case "link"
              html = html + "<tr><td><a target=_blank href=" + objNode2.firstChild.nodevalue + ">"
              html = html + objNode2.firstChild.nodevalue
              html = html + "</a></td></tr>"
            Case "description"
              html = html + "<tr><td>"
              html = html + objNode2.firstChild.nodevalue
              html = html + "</td></tr>"
            End Select
            
        Next
      Next
    
      html = html + "<tr><td><hr></td></tr>"
    
      Set objNodeList = objXML.getElementsByTagName("item")
      For Each objNode In objNodeList
        For Each objNode2 In objNode.childNodes
          
          Select Case objNode2.nodeName
            Case "title"
              strTitle = objNode2.firstChild.nodevalue
            Case "link"
              strURL = objNode2.firstChild.nodevalue
            Case "description"
              strDescription = objNode2.firstChild.nodevalue
          End Select
        Next
        
        html = html + "<tr><td><li/><a target=_blank href=" + strURL + ">"
        html = html + strTitle + "</a>
    " + strDescription +"</td></tr>"
        strTitle = ""
        strURL = ""
        strDescription = ""
      Next
    
      html = "<table width=400>"+html+"</table>"
      set objNodeList = Nothing
    
    End if
    %>
    
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    </head>
    <body>
    
    <% Response.write (html) %>
    
    </body>
    </html>

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    If Not blnLoaded Then

    cosa vorrebbe dire?

    Roby

  5. #5
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400
    Originariamente inviato da Roby_72
    If Not blnLoaded Then

    cosa vorrebbe dire?

    Roby
    Ho provato a toglierlo ma questo è l'output html :

    codice:
    <html>
    
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    
    </head>
    
    <body>
    
    <table width=400><tr><td><hr></td></tr></table>
    
    </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.