<%
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)-
<script language= "javascript tutorial" src= "Other.js" ></script>
<style type= "Text/css Tutorial" >
<!--
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}
-->
</style>
</head><body bgcolor= "#0099CC" text= "#000000" >
<table width= "80%" border= "0" cellspacing= "1" cellpadding= "4" align= "center" bgcolor= "#CCCCCC" >
<tr bgcolor= "#000000" >
<TD colspan= "2" ><font color= "#FFFFFF" > Message pu <a href= "postnew.asp" ><font color= #FFFFFF > write new Message
</font></a></font></td>
</tr>
<%
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 <NewList>
' ObjRootsite.childNodes.item (starnodes) corresponds to the node is <list> node because not to a <list> node so use the item ()
' To identify the current node data, along with the descending of the Starnodes <list> node to move up one by one to read <list> 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 <list> node's child node is what we really want)
'******************************************************************************
Text = replace (TEXT,CHR (), <br>)
' Instead of carriage return
Text = replace (TEXT,CHR (32), "")
' Alternate spaces
%>
<tr bgcolor= "#F0F0F0" >
<TD width= "21%" height= "a" valign= "top" >id:<%=id%><br> name:<%=username%><br>
From:<%=fromwhere%><br>
<a href= ' postedit.asp?id=<%=id%> ' > Editorial message </a>
</td>
<TD width= "79%" height= "valign=" "Top" > | <a href= "<%=homepage%>" Target=_blank title= "<%=username%> Home" > Home </a>
| | <a href= "mailto:<%=email%>" title= "Give <%=username%> write" > Mailbox </a> | |<font color= "#CC6633" >
Message Time:<%=posttime%> </font>|
<hr>
<%=replace (TEXT,CHR, "<br>")%> </td>
</tr>
<tr bgcolor= "#FFFFFF" align= "right" >
<TD colspan= "2" > </td>
</tr>
<%
Starnodes=starnodes-1
Wend
Set objxml=nothing
%>
<tr bgcolor= "#FFFFFF" align= "right" >
<TD colspan= "2" > Total <<%=PageNum%>> page
<%
If CInt (pageno) <>pagenum Then ' paging
Response.Write "<a href=index.asp?" Pageno= "& (pageno+1) &" > Prev </a> "
End If
If CInt (pageno) <>1 Then
Response.Write "<a href=index.asp?" Pageno= "& (PageNo-1) &" > next page </a> "
End If
%>
</td>
</tr>
</table>
</body>
</html>
List.xml file format
<?xml version= "1.0" encoding= "gb2312"?>
<site>
<NewList>
<list>
<id>0</id>
<username>1111</username>
<fromwhere> China </fromwhere>
<posttime>2007-4-20 17:54:35</posttime>
<homepage>http://</homepage>
<email>111</email>
<text>qqqqqqqqq</text>
</list>
<list>
<id>1</id>
<username>sdf</username>
<fromwhere> China </fromwhere>
<posttime>2007-4-25 10:24:03</posttime>
<homepage>http://</homepage>
<email>sdf</email>
<text>wwwwwwwwww</text>
</list>
</NewList>
</site>
Send save to XML document
<%
Username=request.form ("username")
If username<> "" Then
Fromwhere =request.form ("Fromwhere")
Homepage =request.form ("homepage")
Email =request.form ("email")
Text =request.form ("text")
Text =replace (text, "<", "<")
Posttime =now ()
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.XMLDOM")
' Create an XML pair like
Objxml.load (strSourceFile)
' Read the XML file into memory
Set objrootlist = ObjXML.documentElement.selectSingleNode ("NewList")
' Select <NewList> node
If Objrootlist.haschildnodes Then
' Judge <NewList> if there are child nodes (because if each <NewList> 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 <NewList>
' 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 (&CHR) &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& "<list>" &brstr & _
"<id>" &id& "</id>" &brstr & _
"<username>" &username& "</username>" &brstr & _
"<fromwhere>" &fromwhere& "</fromwhere>" &brstr & _
"<Posttime>" &Posttime& "</Posttime>" &brstr & _
"<homepage>" &homepage& "</homepage>" &brstr & _
"<email>" &email& "</email>" &brstr & _
"<text>" &text& "</text>" &brstr & _
"</list>" &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
%>
<html>
<head>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "Author" content= "Promise, Xunuo" >
<title> Web Desktop (XML message board)-Http://www.111cn.net</title>
<script language= "javascript" src= "Other.js" ></script>
<style type= "Text/css" >
<!--
td {FONT-SIZE:9PT}
-->
</style>
</head>
<body bgcolor= "#0099CC" text= "#000000" >
<table width= "80%" border= "0" cellspacing= "1" cellpadding= "4" align= "center" bgcolor= "#FFFFFF" >
<form action= "postnew.asp" method= "Post" Name= "Form1" >
<tr bgcolor= "#000000" >
<TD colspan= "2" ><font color= "#FFFFFF" > New Message </font></td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" > name:</td>
<TD width= "81%" >
<input type= "text" name= "username" >
* * </td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" > from:</td>
<TD width= "81%" >
<input type= "text" name= "Fromwhere" value= "China" >
</td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" > home page:</td>
<TD width= "81%" >
<input type= "text" name= "homepage" value= "http://" >
</td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" >Email:</td>
<TD width= "81%" >
<input type= "text" name= "email" >
</td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" valign= "top" > Content:</td>
<TD width= "81%" >
<textarea name= "text" cols= "rows=" ></textarea>
</td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" > </td>
<TD width= "81%" >
<input type= "Submit" name= "Submission" value= "submitted" >
<input type= "reset" name= "Submit2" value= "refill" >
</td>
</tr>
</form>
</table>
</body>
</html>
Edit an XML document
<%
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, "<", "<")
Posttime =now ()
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.XMLDOM")
' Create an XML pair like
Objxml.load (strSourceFile)
' Read the XML file into memory
Set objrootlist = ObjXML.documentElement.selectSingleNode ("NewList")
' Select <NewList> node
Set Rootoldnode=objrootlist.childnodes.item (ID)
'--------NEW START-----------
BRSTR=CHR (&CHR) &CHR (9)
xmlnode=brstr& "<list>" &brstr & _
"<id>" &id& "</id>" &brstr & _
"<username>" &username& "</username>" &brstr & _
"<fromwhere>" &fromwhere& "</fromwhere>" &brstr & _
"<Posttime>" &Posttime& "</Posttime>" &brstr & _
"<homepage>" &homepage& "</homepage>" &brstr & _
"<email>" &email& "</email>" &brstr & _
"<text>" &text& "</text>" &brstr & _
"</list>" &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 ("./") & "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 <NewList> 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
%>
<html>
<head>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "Author" content= "Promise, Xunuo" >
<title> Web Desktop (XML message board)-Http://www.111cn.net</title>
<script language= "javascript" src= "Other.js" ></script>
<style type= "Text/css" >
<!--
td {FONT-SIZE:9PT}
-->
</style>
</head>
<body bgcolor= "#0099CC" text= "#000000" >
<table width= "80%" border= "0" cellspacing= "1" cellpadding= "4" align= "center" bgcolor= "#FFFFFF" >
<form action= "Postedit.asp?action=update" method= "Post" Name= "Form1" >
<input type= "hidden" value= "<%=id%>" name= "id"/>
<tr bgcolor= "#000000" >
<TD colspan= "2" ><font color= "#FFFFFF" > New Message </font></td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" > name:</td>
<TD width= "81%" >
<input type= "text" name= "username" value= "<%=username%>" >
* * </td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" > from:</td>
<TD width= "81%" >
<input type= "text" name= "Fromwhere" value= "<%=fromwhere%>" >
</td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" > home page:</td>
<TD width= "81%" >
<input type= "text" name= "homepage" value= "<%=homepage%>" >
</td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" >Email:</td>
<TD width= "81%" >
<input type= "text" name= "email" value= "<%=email%>" >
</td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" valign= "top" > Content:</td>
<TD width= "81%" >
<textarea name= "text" cols= "rows=" ><%=text%></textarea>
</td>
</tr>
<tr bgcolor= "#EFEFEF" >
<TD width= "19%" align= "right" > </td>
<TD width= "81%" >
<input type= "Submit" name= "Submission" value= "submitted" >
<input type= "reset" name= "Submit2" value= "refill" >
</td>
</tr>
</form>
</table>
</body>
</html>
The JS file that will be used
Function Print Copyright
function Printcopy () {
WR ("<div style= ' background: #ffffff;p osition:absolute;bottom:10;" ><input type= ' button ' onclick= ' value= ' recommended to friends ' > <input type= ' button ' onclick= ' Copyurl (); ' value= ' Copy to Clipboard ' ></div> ");
WR ("<div style= ' background: #ffffff;p osition:absolute;left:10;width:100;top:10 ' > Description: Reprint the contents of the site, please be sure to retain the original author information." <br> 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. <span style= ' font-size:12px;color: #ff0000 ' >[<a href= '/message.asp's target= ' _blank ' > Notepad </a>][ <a href= ' http://www.111cn.net/' > enter Home </a>]</span></div> ");
}
Function Print Ad
function Printad () {
WR ("<div style= ' position:absolute;top:10;right:10;z-index:10;background: #ffffff ' > for advertising and friendship links <br> Please contact <a href= ' mailto:lffxunuo@163.com ' >lffxunuo@163.com</a></div> ')
}
Printcopy ()
Printad ()
function WR (str) {
document.write (str);
}
function Gotoxunuo () {
window.open ("http://www.111cn.net/")
}