亚洲av色香蕉一区二区三区,十四以下岁毛片带血a级,亚洲 校园 欧美 国产 另类,亚洲av日韩av一区谷露,色欲av无码一区二区三区

  • 相關(guān)軟件
    >利用XML開發(fā)留言板簡(jiǎn)單的例子 創(chuàng)建者:webmaster 更新時(shí)間:2005-07-02 00:37

    XML是一種基于文本格式的元標(biāo)記語言,它注重對(duì)數(shù)據(jù)結(jié)構(gòu)和數(shù)據(jù)意義的描述,實(shí)現(xiàn)了數(shù)據(jù)內(nèi)容和顯示樣式的分離(xml+xsl),而且是與平臺(tái)無關(guān)的。

    由于XML注重?cái)?shù)據(jù)內(nèi)容的描述,因而,對(duì)于數(shù)據(jù)的檢索非常有意義,我們不會(huì)再象HTML那樣,檢索出與我們要求無關(guān)的信息。

    另一方面,XML文件是數(shù)據(jù)的載體,利用XML作為數(shù)據(jù)庫,不需要訪問任何數(shù)據(jù)庫系統(tǒng),我們可以使用任意WEB技術(shù)來顯示我們的數(shù)據(jù),比如HTML,F(xiàn)lashMX 等。

    由于世界各大計(jì)算機(jī)公司的積極參與,XML正日益成為基于互聯(lián)網(wǎng)的數(shù)據(jù)格式新一代的標(biāo)準(zhǔn)。

    下面利用XML作為數(shù)據(jù)的載體,開發(fā)一個(gè)基于XML的留言板。
    ?
    首先,我們建立XML文件guestbook.xml,該文件記錄了留言者的姓名、電子郵件、網(wǎng)址、留言內(nèi)容。當(dāng)然,我們也可以根據(jù)需要添加任意多的信息。文件內(nèi)容如下:
     

    <留言本>
    <留言記錄>
    <留言者姓名>KAI
    <電子郵件>kai@hostx.org
    <網(wǎng)址>http://www.17xml.com
    <留言內(nèi)容>千山萬水總是情,常來泡妞行不行?咔咔:_)


     
    由于目前許多服務(wù)器都支持ASP,我們采用常見的ASP來作為實(shí)現(xiàn)的工具,guestbook.asp文件如下:
     
    <mailto:%@Language="VBScript">
    <%
    '設(shè)置Web頁面的信息
    Response.Buffer = true
    Response.Expires = -1
     
    '顯示留言函數(shù)init()
    'www.knowsky.com
    Function init()
    entryForm()
     
    '定義局部變量
    Dim objXML
    Dim arrNames
    Dim arrEmails
    Dim arrURLS
    Dim arrMessages
     
    '創(chuàng)建XMLDOM文檔對(duì)象,用來存放留言
    Set objXML = server.createObject("Msxml2.DOMDocument")
    objXML.async = false
    objXML.load(server.MapPath("guestbook.xml"))
     
    '取得留言本各元素的集合
    Set arrNames = objXML.getElementsByTagName("留言者姓名")
    Set arrEmails = objXML.getElementsByTagName("電子郵件")
    Set arrURLS = objXML.getElementsByTagName("網(wǎng)址")
    Set arrMessages = objXML.getElementsByTagName("留言內(nèi)容")
     
    Response.Write "

    "
    Response.Write ""
     
    '輸出留言本各元素的內(nèi)容,最新的留言先顯示
    For x=arrNames.length-1 To 0 Step -1
    Response.Write ""
    Response.Write ""
    Response.Write ""
    Response.Write ""
    Response.Write ""
    Next
     
    Response.Write "
    "
    Response.Write "各位的留言如下:"
    Response.Write "
    " & arrNames.item(x).text & "
    網(wǎng)址:" & arrURLS.item(x).text & "
    留言內(nèi)容:
    " & arrMessages.item(x).text &"
    "
    Set objXML = nothing
    End Function
     
    '向XML文件添加留言記錄的函數(shù)addEntry()
    Function addEntry()
     
    '定義局部變量
    Dim strName
    Dim strEmail
    Dim strURL
    Dim strMessage
     
    '取得留言表單的輸入內(nèi)容
    strName = Request.Form("姓名")
    strEmail = Request.Form("電子郵件")
    strURL = Request.Form("網(wǎng)址")
    strMessage = Request.Form("留言")
     
    Dim objXML
    Dim objEntry
    Dim objName
    Dim objEmail
    Dim objURL
    Dim objMessage
     
    '向XML文件添加留言內(nèi)容
    Set objXML = server.createObject("Msxml2.DOMDocument")
    objXML.async = false
    objXML.load(server.MapPath("guestbook.xml"))
     
    Set objEntry = objXML.createNode("element", "留言記錄", "")
    objXML.documentElement.appendChild(objEntry)
     
    Set objName = objXML.createNode("element", "留言者姓名", "")
    objEntry.appendChild(objName)
    objName.text = strName
     
    Set objEmail = objXML.createNode("element", "電子郵件", "")
    objEntry.appendChild(objEmail)
    objEmail.text = strEmail
     
    Set objURL = objXML.createNode("element", "網(wǎng)址", "")
    objEntry.appendChild(objURL)
    objURL.text = strURL
     
    Set objMessage = objXML.createNode("element", "留言內(nèi)容", "")
    objEntry.appendChild(objMessage)
    objMessage.text = strMessage
     
    objXML.save(server.MapPath("guestbook.xml"))
     
    Response.Redirect("guestbook.asp")
     
    End function
     
    '填寫和發(fā)送留言表單的函數(shù)entryForm()
    Function entryForm()
     
    Response.Write "

    XML 留言本 例子

    "
    Response.Write "
    "
    Response.Write "
    "
    Response.Write ""
    Response.Write ""
    Response.Write ""
    Response.Write ""
    Response.Write ""
    Response.Write ""
    Response.Write "
    您的姓名:
    電子郵件:
    您的網(wǎng)址:
    您的留言:
    "
    Response.Write "
    "
     
    End Function
    %>


    XML 留言例子



    <%
    '判斷是否發(fā)送了留言,并更新留言信息
    Dim a
    a = Request.Querystring("action")
    If a<>"" Then
    addEntry
    else
    init
    End If
    %>


     
    以上是利用XML開發(fā)留言板簡(jiǎn)單的例子,完全是拋磚引玉,可以根據(jù)需要進(jìn)行添加更多的功能,所有程序在WIN2000+IIS5.0+IE5.5調(diào)試通過.

    相關(guān)文章
    本頁查看次數(shù):