The following uses XML as the carrier of data to develop an XML-based message board.
First, we create an XML file that records the name, email, URL, and message content of the commentator. Of course, we can also add as much information as we need. The file contents are as follows:
<?xml version="1.0" encoding="gb2312"?>
<Message Book>
<Message Record>
<Name of the message>KAI</Name of the message>
<Email>kai@</Email>
<Website>http:// </website>
<Message content>From mountains and rivers, can you always pick up girls? Kaka:_)</Message Content>
</Message Record>
</Message Book>
Since many servers currently support ASP, we use common ASP as implementation tool, and the files are as follows:
<%@Language="VBScript"%>
<%
'Set the information of the web page
= true
= -1
'Show message function init()
'
Function init()
entryForm()
'Define local variables
Dim objXML
Dim arrNames
Dim arrEmails
Dim arrURLS
Dim arrMessages
'Create XMLDOM document object to store messages
Set objXML = ("")
= false
((""))
'Get a collection of elements of the message book
Set arrNames = ("Message name")
Set arrEmails = ("Email")
Set arrURLS = ("Website")
Set arrMessages = ("Message Content")
"<table border='0' width='100%'>"
"<tr><td bgcolor='#00CCFF' align='center' height='26'>"
"<b>Dear comments are as follows:</b>"
"</td></tr>"
'Output content of each element of the message book, the latest message will be displayed first
For x=-1 To 0 Step -1
"<tr><td><a href=mailto:" & (x).text & ">" & (x).text & "</a></td></tr>"
"<tr><td>Website: <a href=" & (x).text & " target='_blank'>" & (x).text & "</a><td></tr>"
"<tr><td>Message content:</td></tr>"
"<tr><td bgcolor='#0099ff'>" & (x).text &"</td></tr>"
"<tr><td> </td></tr>"
Next
"</table>"
Set objXML = nothing
End Function
'The function to add message record to the XML file addEntry()
Function addEntry()
'Define local variables
Dim strName
Dim strEmail
Dim strURL
Dim strMessage
'Get input content of the message form
strName = ("Name")
strEmail = ("Email")
strURL = ("Website")
strMessage = ("Leave a message")
Dim objXML
Dim objEntry
Dim objName
Dim objEmail
Dim objURL
Dim objMessage
'Add message content to XML file
Set objXML = ("")
= false
((""))
Set objEntry = ("element", "Message Record", "")
(objEntry)
Set objName = ("element", "name of the commentator", "")
(objName)
= strName
Set objEmail = ("element", "email", "")
(objEmail)
= strEmail
Set objURL = ("element", "website", "")
(objURL)
= strURL
Set objMessage = ("element", "Message Content", "")
(objMessage)
= strMessage
((""))
("")
End function
'Fill in and send message form function entryForm()
Function entryForm()
"<p align='center'><b>XML message book Example</b></p>"
"<hr color='#000099' width='100%' noshade>"
"<form action=?action=addEntry method=post>"
"<table border=1>"
"<tr><td>Your name:</td><td><input type=text name=name /></td></tr>"
"<tr><td>Email:</td><td><input type=text name=email /></td></tr>"
"<tr><td>Your URL: </td><td><input type=text name=website /></td></tr>"
"<tr><td>Your message: </td><td><textarea name=Message cols=40 rows=5></textarea></td></tr>"
"<tr><td> </td><td><input type=submit value=Post a message /></td></tr>"
"</table>"
"</form>"
End Function
%>
<html>
<head>
<title>XML message example</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
'Judge whether a message has been sent and update the message information
Dim a
a = ("action")
If a<>"" Then
addEntry
else
init
End If
%>
</body>
</html>
The above is a simple example of using XML to develop message boards. It is a complete introduction to the situation. You can add more functions as needed. All programs are debugged and passed in WIN2000+IIS5.0+IE5.5.
First, we create an XML file that records the name, email, URL, and message content of the commentator. Of course, we can also add as much information as we need. The file contents are as follows:
<?xml version="1.0" encoding="gb2312"?>
<Message Book>
<Message Record>
<Name of the message>KAI</Name of the message>
<Email>kai@</Email>
<Website>http:// </website>
<Message content>From mountains and rivers, can you always pick up girls? Kaka:_)</Message Content>
</Message Record>
</Message Book>
Since many servers currently support ASP, we use common ASP as implementation tool, and the files are as follows:
<%@Language="VBScript"%>
<%
'Set the information of the web page
= true
= -1
'Show message function init()
'
Function init()
entryForm()
'Define local variables
Dim objXML
Dim arrNames
Dim arrEmails
Dim arrURLS
Dim arrMessages
'Create XMLDOM document object to store messages
Set objXML = ("")
= false
((""))
'Get a collection of elements of the message book
Set arrNames = ("Message name")
Set arrEmails = ("Email")
Set arrURLS = ("Website")
Set arrMessages = ("Message Content")
"<table border='0' width='100%'>"
"<tr><td bgcolor='#00CCFF' align='center' height='26'>"
"<b>Dear comments are as follows:</b>"
"</td></tr>"
'Output content of each element of the message book, the latest message will be displayed first
For x=-1 To 0 Step -1
"<tr><td><a href=mailto:" & (x).text & ">" & (x).text & "</a></td></tr>"
"<tr><td>Website: <a href=" & (x).text & " target='_blank'>" & (x).text & "</a><td></tr>"
"<tr><td>Message content:</td></tr>"
"<tr><td bgcolor='#0099ff'>" & (x).text &"</td></tr>"
"<tr><td> </td></tr>"
Next
"</table>"
Set objXML = nothing
End Function
'The function to add message record to the XML file addEntry()
Function addEntry()
'Define local variables
Dim strName
Dim strEmail
Dim strURL
Dim strMessage
'Get input content of the message form
strName = ("Name")
strEmail = ("Email")
strURL = ("Website")
strMessage = ("Leave a message")
Dim objXML
Dim objEntry
Dim objName
Dim objEmail
Dim objURL
Dim objMessage
'Add message content to XML file
Set objXML = ("")
= false
((""))
Set objEntry = ("element", "Message Record", "")
(objEntry)
Set objName = ("element", "name of the commentator", "")
(objName)
= strName
Set objEmail = ("element", "email", "")
(objEmail)
= strEmail
Set objURL = ("element", "website", "")
(objURL)
= strURL
Set objMessage = ("element", "Message Content", "")
(objMessage)
= strMessage
((""))
("")
End function
'Fill in and send message form function entryForm()
Function entryForm()
"<p align='center'><b>XML message book Example</b></p>"
"<hr color='#000099' width='100%' noshade>"
"<form action=?action=addEntry method=post>"
"<table border=1>"
"<tr><td>Your name:</td><td><input type=text name=name /></td></tr>"
"<tr><td>Email:</td><td><input type=text name=email /></td></tr>"
"<tr><td>Your URL: </td><td><input type=text name=website /></td></tr>"
"<tr><td>Your message: </td><td><textarea name=Message cols=40 rows=5></textarea></td></tr>"
"<tr><td> </td><td><input type=submit value=Post a message /></td></tr>"
"</table>"
"</form>"
End Function
%>
<html>
<head>
<title>XML message example</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
'Judge whether a message has been sent and update the message information
Dim a
a = ("action")
If a<>"" Then
addEntry
else
init
End If
%>
</body>
</html>
The above is a simple example of using XML to develop message boards. It is a complete introduction to the situation. You can add more functions as needed. All programs are debugged and passed in WIN2000+IIS5.0+IE5.5.