Asp+xml No database Message board system

Source: Internet
Author: User
Tags chr

<%
strSourceFile = Server.MapPath ("./") & "List.xml"
' Get the path to the XML file, which is different depending on your virtual directory.
Set objxml = Server.CreateObject ("Microsoft.FreeThreadedXMLDOM")
' Create an XML pair as a free thread
Objxml.load (strsourcefile) ' reads the XML file into memory
Set objrootsite = ObjXML.documentElement.selectSingleNode ("NewList")
' Select the NewList node
%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "Author" content= "Promise, Xunuo" >
<title> Web Desktop (XML message board)-

&lt;script language= "javascript tutorial" src= "Other.js" &gt;&lt;/script&gt;


&lt;style type= "Text/css Tutorial" &gt;


&lt;!--


TD {Font-family: "Song body"; font-size:9pt; Text-decoration:none}


A {font-family: "Song body"; Font-size:9pt color: #0066CC; Text-decoration:none}


a:hover {color: #FF6600; Text-decoration:underline}


--&gt;


&lt;/style&gt;


&lt;/head&gt;&lt;body bgcolor= "#0099CC" text= "#000000" &gt;


&lt;table width= "80%" border= "0" cellspacing= "1" cellpadding= "4" align= "center" bgcolor= "#CCCCCC" &gt;


&lt;tr bgcolor= "#000000" &gt;


&LT;TD colspan= "2" &gt;&lt;font color= "#FFFFFF" &gt; Message pu &lt;a href= "postnew.asp" &gt;&lt;font color= #FFFFFF &gt; write new Message


&lt;/font&gt;&lt;/a&gt;&lt;/font&gt;&lt;/td&gt;


&lt;/tr&gt;


&lt;%


PageSize = 10 ' Suppose each page shows 10 messages


Allnodesnum =objrootsite.childnodes.length-1


' Response.Write objRootsite.childNodes.length


' Response.End


' Get the child node data (since the maximum number of child nodes from the number of nodes is 0 minus 1)


Pagenum=allnodesnumpagesize+1 ' Calculate the total number of pages


Pageno=request.querystring ("PageNo")

If pageno= "then" if it is every time you get the page, navigate to each page to display the latest message
Pageno=pagenum
End If

Starnodes=pageno*pagesize-1 ' Get Start node
Endnodes= (PageNo-1) *pagesize ' Get End node

If Endnodes<0 Then
Endnodes=0
End If
' Response.Write ' starnodes and allnodesnum=== ' &starnodes & '----' &AllNOdesNum& ' <br> '
If Starnodes>allnodesnum then ' determines whether the number of starting nodes exceeds the total number of nodes
endnodes=endnodes-(Starnodes-allnodesnum)
' If the difference between the end node minus (Starnodes-allnodesnum) is exceeded, the next rcas is out of bounds error
Starnodes=allnodesnum
End If
' Response.Write ' starnodes=_________ ' &starnodes & '---' & ' <br> '
If Endnodes<0 Then
Endnodes=0
End If
While Starnodes>=endnodes
' Read node data from end node to super start node
' Response.Write ' id= ' &objrootsite.childnodes.item (starnodes). Childnodes.item (0). Text

id = ObjRootsite.childNodes.item (starnodes). Childnodes.item (0). Text


' ID number


Username = ObjRootsite.childNodes.item (starnodes). Childnodes.item (1). Text


' Get user name


Fromwhere = ObjRootsite.childNodes.item (starnodes). Childnodes.item (2). Text


' Get users from there


Posttime = ObjRootsite.childNodes.item (starnodes). Childnodes.item (3). Text


' Get message time


Homepage = ObjRootsite.childNodes.item (starnodes). Childnodes.item (4). Text


' Get user homepage


email = objRootsite.childNodes.item (starnodes). Childnodes.item (5). Text


' Get user Eamil


Text = ObjRootsite.childNodes.item (starnodes). Childnodes.item (6). Text


' Received yesterday's message content


'*****************************************************************************


' This makes the DOM of XML read the data, obviously objrootsite the corresponding node for the &lt;NewList&gt;


' ObjRootsite.childNodes.item (starnodes) corresponds to the node is &lt;list&gt; node because not to a &lt;list&gt; node so use the item ()


' To identify the current node data, along with the descending of the Starnodes &lt;list&gt; node to move up one by one to read &lt;list&gt; node data.


' ObjRootsite.childNodes.item (starnodes). Childnodes.item (1). text corresponds to the node as a concrete value for each node, here


' (1) corresponds to the username username (because &lt;list&gt; node's child node is what we really want)


'******************************************************************************


Text = replace (TEXT,CHR (), &lt;br&gt;)


' Instead of carriage return


Text = replace (TEXT,CHR (32), "")


' Alternate spaces


%&gt;


&lt;tr bgcolor= "#F0F0F0" &gt;


&LT;TD width= "21%" height= "a" valign= "top" &gt;id:&lt;%=id%&gt;&lt;br&gt; name:&lt;%=username%&gt;&lt;br&gt;


From:&lt;%=fromwhere%&gt;&lt;br&gt;


&lt;a href= ' postedit.asp?id=&lt;%=id%&gt; ' &gt; Editorial message &lt;/a&gt;


&lt;/td&gt;


&LT;TD width= "79%" height= "valign=" "Top" &gt; | &lt;a href= "&lt;%=homepage%&gt;" Target=_blank title= "&lt;%=username%&gt; Home" &gt; Home &lt;/a&gt;


| | &lt;a href= "mailto:&lt;%=email%&gt;" title= "Give &lt;%=username%&gt; write" &gt; Mailbox &lt;/a&gt; | |&lt;font color= "#CC6633" &gt;


Message Time:&lt;%=posttime%&gt; &lt;/font&gt;|


&lt;hr&gt;


&lt;%=replace (TEXT,CHR, "&lt;br&gt;")%&gt; &lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#FFFFFF" align= "right" &gt;


&LT;TD colspan= "2" &gt; &lt;/td&gt;


&lt;/tr&gt;


&lt;%


Starnodes=starnodes-1


Wend


Set objxml=nothing


%&gt;


&lt;tr bgcolor= "#FFFFFF" align= "right" &gt;


&LT;TD colspan= "2" &gt; Total &lt;&lt;%=PageNum%&gt;&gt; page


&lt;%


If CInt (pageno) &lt;&gt;pagenum Then ' paging


Response.Write "&lt;a href=index.asp?" Pageno= "&amp; (pageno+1) &amp;" &gt; Prev &lt;/a&gt; "


End If


If CInt (pageno) &lt;&gt;1 Then


Response.Write "&lt;a href=index.asp?" Pageno= "&amp; (PageNo-1) &amp;" &gt; next page &lt;/a&gt; "


End If


%&gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;/table&gt;


&lt;/body&gt;


&lt;/html&gt;

List.xml file format

&lt;?xml version= "1.0" encoding= "gb2312"?&gt;


&lt;site&gt;


&lt;NewList&gt;


&lt;list&gt;


&lt;id&gt;0&lt;/id&gt;


&lt;username&gt;1111&lt;/username&gt;


&lt;fromwhere&gt; China &lt;/fromwhere&gt;


&lt;posttime&gt;2007-4-20 17:54:35&lt;/posttime&gt;


&lt;homepage&gt;http://&lt;/homepage&gt;


&lt;email&gt;111&lt;/email&gt;


&lt;text&gt;qqqqqqqqq&lt;/text&gt;


&lt;/list&gt;


&lt;list&gt;


&lt;id&gt;1&lt;/id&gt;


&lt;username&gt;sdf&lt;/username&gt;


&lt;fromwhere&gt; China &lt;/fromwhere&gt;


&lt;posttime&gt;2007-4-25 10:24:03&lt;/posttime&gt;


&lt;homepage&gt;http://&lt;/homepage&gt;


&lt;email&gt;sdf&lt;/email&gt;


&lt;text&gt;wwwwwwwwww&lt;/text&gt;


&lt;/list&gt;


&lt;/NewList&gt;


&lt;/site&gt;

Send save to XML document

&lt;%


Username=request.form ("username")


If username&lt;&gt; "" Then


Fromwhere =request.form ("Fromwhere")


Homepage =request.form ("homepage")


Email =request.form ("email")


Text =request.form ("text")


Text =replace (text, "&lt;", "&lt;")


Posttime =now ()


strSourceFile = Server.MapPath ("./") &amp; "List.xml"


' Get the path to the XML file, which is different depending on your virtual directory.


Set objxml = Server.CreateObject ("Microsoft.XMLDOM")


' Create an XML pair like


Objxml.load (strSourceFile)


' Read the XML file into memory


Set objrootlist = ObjXML.documentElement.selectSingleNode ("NewList")


' Select &lt;NewList&gt; node


If Objrootlist.haschildnodes Then


' Judge &lt;NewList&gt; if there are child nodes (because if each &lt;NewList&gt; is not a child node, if you do not add a judgment on the first shipment will be an error


id = objrootlist.lastchild.firstchild.text+1


' Here gets the ID number of the child node that will be inserted, with the ID number of the first child node (firstchild) of the Last child node (lastchild) of &lt;NewList&gt;


' ID number plus 1 (here we increment according to the ID number of the relational database)


Else


' If no word child node is the first time message ID number set to 1


Id=1


End If


BRSTR=CHR (&AMP;CHR) &AMP;CHR (9)


' To insert the nodes in the XML file to line up lines of space


' (Of course you can not do this just for the sake of XML data.)


xmlnode=brstr&amp; "&lt;list&gt;" &amp;brstr &amp; _


"&lt;id&gt;" &amp;id&amp; "&lt;/id&gt;" &amp;brstr &amp; _


"&lt;username&gt;" &amp;username&amp; "&lt;/username&gt;" &amp;brstr &amp; _


"&lt;fromwhere&gt;" &amp;fromwhere&amp; "&lt;/fromwhere&gt;" &amp;brstr &amp; _


"&lt;Posttime&gt;" &amp;Posttime&amp; "&lt;/Posttime&gt;" &amp;brstr &amp; _


"&lt;homepage&gt;" &amp;homepage&amp; "&lt;/homepage&gt;" &amp;brstr &amp; _


"&lt;email&gt;" &amp;email&amp; "&lt;/email&gt;" &amp;brstr &amp; _


"&lt;text&gt;" &amp;text&amp; "&lt;/text&gt;" &amp;brstr &amp; _


"&lt;/list&gt;" &AMP;CHR (13)


' Create an XML fragment based on the resulting data


Set Objxml2=server.createobject ("Microsoft.XMLDOM")


' Create a new XML pair like


Objxml2.loadxml (XMLnode)


' Read the XML fragment into memory


Set Rootnewnode=objxml2.documentelement


' Get the root node of objXML2


Objrootlist.appendchild (Rootnewnode)


' Insert the XML fragment into the List.xml


Objxml.save (strSourceFile)


' Store Lsit.xml file (because no storage list.xml is updated in memory only)


Set objxml=nothing


Set objxml2=nothing


Response.Redirect ("index.asp")


Response.End


End If


%&gt;


&lt;html&gt;


&lt;head&gt;


&lt;meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "&gt;


&lt;meta name= "Author" content= "Promise, Xunuo" &gt;


&lt;title&gt; Web Desktop (XML message board)-Http://www.111cn.net&lt;/title&gt;


&lt;script language= "javascript" src= "Other.js" &gt;&lt;/script&gt;


&lt;style type= "Text/css" &gt;


&lt;!--


td {FONT-SIZE:9PT}


--&gt;


&lt;/style&gt;


&lt;/head&gt;


&lt;body bgcolor= "#0099CC" text= "#000000" &gt;


&lt;table width= "80%" border= "0" cellspacing= "1" cellpadding= "4" align= "center" bgcolor= "#FFFFFF" &gt;


&lt;form action= "postnew.asp" method= "Post" Name= "Form1" &gt;


&lt;tr bgcolor= "#000000" &gt;


&LT;TD colspan= "2" &gt;&lt;font color= "#FFFFFF" &gt; New Message &lt;/font&gt;&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt; name:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "text" name= "username" &gt;


* * &lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt; from:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "text" name= "Fromwhere" value= "China" &gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt; home page:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "text" name= "homepage" value= "http://" &gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt;Email:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "text" name= "email" &gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" valign= "top" &gt; Content:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;textarea name= "text" cols= "rows=" &gt;&lt;/textarea&gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt; &lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "Submit" name= "Submission" value= "submitted" &gt;


&lt;input type= "reset" name= "Submit2" value= "refill" &gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;/form&gt;


&lt;/table&gt;


&lt;/body&gt;


&lt;/html&gt;


Edit an XML document

&lt;%


Dim id, Action


id = request.querystring ("id")


If IsNumeric (ID) =false or isNull (ID) Then


Response.Write ("parameter is not correct, please return!") ")


Response.End


End If


Action = request.querystring ("action")


id = ID


If action = "Update" Then


id = Request ("id")


Username=request.form ("username")


Fromwhere =request.form ("Fromwhere")


Homepage =request.form ("homepage")


Email =request.form ("email")


Text =request.form ("text")


Text =replace (text, "&lt;", "&lt;")


Posttime =now ()


strSourceFile = Server.MapPath ("./") &amp; "List.xml"


' Get the path to the XML file, which is different depending on your virtual directory.


Set objxml = Server.CreateObject ("Microsoft.XMLDOM")


' Create an XML pair like


Objxml.load (strSourceFile)


' Read the XML file into memory


Set objrootlist = ObjXML.documentElement.selectSingleNode ("NewList")


' Select &lt;NewList&gt; node





Set Rootoldnode=objrootlist.childnodes.item (ID)


'--------NEW START-----------


BRSTR=CHR (&AMP;CHR) &AMP;CHR (9)


xmlnode=brstr&amp; "&lt;list&gt;" &amp;brstr &amp; _


"&lt;id&gt;" &amp;id&amp; "&lt;/id&gt;" &amp;brstr &amp; _


"&lt;username&gt;" &amp;username&amp; "&lt;/username&gt;" &amp;brstr &amp; _


"&lt;fromwhere&gt;" &amp;fromwhere&amp; "&lt;/fromwhere&gt;" &amp;brstr &amp; _


"&lt;Posttime&gt;" &amp;Posttime&amp; "&lt;/Posttime&gt;" &amp;brstr &amp; _


"&lt;homepage&gt;" &amp;homepage&amp; "&lt;/homepage&gt;" &amp;brstr &amp; _


"&lt;email&gt;" &amp;email&amp; "&lt;/email&gt;" &amp;brstr &amp; _


"&lt;text&gt;" &amp;text&amp; "&lt;/text&gt;" &amp;brstr &amp; _


"&lt;/list&gt;" &AMP;CHR (13)


' Create an XML fragment based on the resulting data


Set Objxml2=server.createobject ("Microsoft.XMLDOM")


' Create a new XML pair like


Objxml2.loadxml (XMLnode)


' Read the XML fragment into memory


Set Rootnewnode=objxml2.documentelement


' ===========new=============


Objrootlist.replacechild Rootnewnode,rootoldnode


Objxml.save (strSourceFile)


Set objxml=nothing


Set objxml2=nothing


Response.Redirect ("index.asp")


Response.End


Else


strSourceFile = Server.MapPath ("./") &amp; "List.xml"


' Get the path to the XML file, which is different depending on your virtual directory.


Set objxml = Server.CreateObject ("Microsoft.XMLDOM")


' Create an XML pair like


Objxml.load (strSourceFile)


' Read the XML file into memory


Set objrootsite = ObjXML.documentElement.selectSingleNode ("NewList")


' Select &lt;NewList&gt; node


' Response.Write ObjRootsite.childNodes.item (ID). Childnodes.item (1). Text


' Response.End


id = objRootsite.childNodes.item (ID). Childnodes.item (0). Text


' ID number


Username = ObjRootsite.childNodes.item (id). Childnodes.item (1). Text


' Get user name


Fromwhere = ObjRootsite.childNodes.item (ID). Childnodes.item (2). Text


' Get users from there


Posttime = ObjRootsite.childNodes.item (ID). Childnodes.item (3). Text


' Get message time


Homepage = ObjRootsite.childNodes.item (ID). Childnodes.item (4). Text


' Get user homepage


email = objRootsite.childNodes.item (ID). Childnodes.item (5). Text


' Get user Eamil


Text = ObjRootsite.childNodes.item (ID). Childnodes.item (6). Text


Set objxml = Nothing


End If


%&gt;

&lt;html&gt;


&lt;head&gt;


&lt;meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "&gt;


&lt;meta name= "Author" content= "Promise, Xunuo" &gt;


&lt;title&gt; Web Desktop (XML message board)-Http://www.111cn.net&lt;/title&gt;


&lt;script language= "javascript" src= "Other.js" &gt;&lt;/script&gt;


&lt;style type= "Text/css" &gt;


&lt;!--


td {FONT-SIZE:9PT}


--&gt;


&lt;/style&gt;


&lt;/head&gt;


&lt;body bgcolor= "#0099CC" text= "#000000" &gt;


&lt;table width= "80%" border= "0" cellspacing= "1" cellpadding= "4" align= "center" bgcolor= "#FFFFFF" &gt;


&lt;form action= "Postedit.asp?action=update" method= "Post" Name= "Form1" &gt;


&lt;input type= "hidden" value= "&lt;%=id%&gt;" name= "id"/&gt;


&lt;tr bgcolor= "#000000" &gt;


&LT;TD colspan= "2" &gt;&lt;font color= "#FFFFFF" &gt; New Message &lt;/font&gt;&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt; name:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "text" name= "username" value= "&lt;%=username%&gt;" &gt;


* * &lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt; from:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "text" name= "Fromwhere" value= "&lt;%=fromwhere%&gt;" &gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt; home page:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "text" name= "homepage" value= "&lt;%=homepage%&gt;" &gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt;Email:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "text" name= "email" value= "&lt;%=email%&gt;" &gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" valign= "top" &gt; Content:&lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;textarea name= "text" cols= "rows=" &gt;&lt;%=text%&gt;&lt;/textarea&gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;tr bgcolor= "#EFEFEF" &gt;


&LT;TD width= "19%" align= "right" &gt; &lt;/td&gt;


&LT;TD width= "81%" &gt;


&lt;input type= "Submit" name= "Submission" value= "submitted" &gt;


&lt;input type= "reset" name= "Submit2" value= "refill" &gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;/form&gt;


&lt;/table&gt;


&lt;/body&gt;


&lt;/html&gt;


The JS file that will be used

Function Print Copyright


function Printcopy () {


WR ("&lt;div style= ' background: #ffffff;p osition:absolute;bottom:10;" &gt;&lt;input type= ' button ' onclick= ' value= ' recommended to friends ' &gt; &lt;input type= ' button ' onclick= ' Copyurl (); ' value= ' Copy to Clipboard ' &gt;&lt;/div&gt; ");


WR ("&lt;div style= ' background: #ffffff;p osition:absolute;left:10;width:100;top:10 ' &gt; Description: Reprint the contents of the site, please be sure to retain the original author information." &lt;br&gt; site to provide the most information or software is collected online, infringing your copyright, please write to tell us that this site will delete these content. &lt;span style= ' font-size:12px;color: #ff0000 ' &gt;[&lt;a href= '/message.asp's target= ' _blank ' &gt; Notepad &lt;/a&gt;][ &lt;a href= ' http://www.111cn.net/' &gt; enter Home &lt;/a&gt;]&lt;/span&gt;&lt;/div&gt; ");


}


Function Print Ad


function Printad () {


WR ("&lt;div style= ' position:absolute;top:10;right:10;z-index:10;background: #ffffff ' &gt; for advertising and friendship links &lt;br&gt; Please contact &lt;a href= ' mailto:lffxunuo@163.com ' &gt;lffxunuo@163.com&lt;/a&gt;&lt;/div&gt; ')


}


Printcopy ()


Printad ()


function WR (str) {


document.write (str);


}


function Gotoxunuo () {


window.open ("http://www.111cn.net/")


}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.